-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebp.monkey
More file actions
74 lines (58 loc) · 1.8 KB
/
webp.monkey
File metadata and controls
74 lines (58 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
' Monkey WebP
' ===========
'
' See the README.md for more information
'
Strict
Import mojo
Import mojo.data
Import mojo.graphicsdevice
#If TARGET="android" And LANG="java"
#WEBP_IMPLEMENTED=True
Import "native/webp.${TARGET}.${LANG}"
Extern
Class WebPGlue
Function LoadSurface:Surface(path:String)
End Class
#ElseIf TARGET="ios" And LANG="cpp"
#WEBP_IMPLEMENTED=True
#LIBS+="${CD}/native/webp-android-backport/webp-android-backport-library/jni/webp/WebP.framework/WebP.a"
#LIBS+="${CD}/native/webp-android-backport/webp-android-backport-library/jni/webp/WebP.framework/Headers/decode.h"
#LIBS+="${CD}/native/webp-android-backport/webp-android-backport-library/jni/webp/WebP.framework/Headers/types.h"
Import "native/webp.${TARGET}.${LANG}"
Extern
Class WebPGlue
Function LoadSurface:Surface(path:String)
End Class
#EndIf
#WEBP_IMPLEMENTED=False
Public
#If WEBP_IMPLEMENTED
Class WebP
Function LoadImage:Image( path:String, frameCount:Int=1, flags:Int=Image.DefaultFlags )
Local surf := WebPGlue.LoadSurface( FixDataPath(path) )
If surf Then
Return (New Image()).Init(surf, frameCount, flags)
End If
Return Null
End Function
Function LoadImage:Image( path:String, frameWidth:Int, frameHeight:Int, frameCount:Int, flags:Int=Image.DefaultFlags )
Local atlas := WebP.LoadImage(path, 1, 0)
If atlas Then
Return atlas.GrabImage(0, 0, frameWidth, frameHeight, frameCount, flags)
End If
Return Null
End Function
End Class
#Else
Class WebP
Function LoadImage:Image(path:String, frameCount:Int=1, flags:Int=Image.DefaultFlags)
Error("WebP is not available.")
Return Null
End Function
Function LoadImage:Image(path:String, frameWidth:Int, frameHeight:Int, frameCount:Int, flags:Int=Image.DefaultFlags)
Error("WebP is not available.")
Return Null
End Function
End Class
#EndIf