@@ -28,6 +28,7 @@ struct PiuGIFImageStruct {
28
28
PiuBehaviorPart ;
29
29
PiuContentPart ;
30
30
xsSlot * path ;
31
+ xsSlot * buffer ;
31
32
PiuColorRecord color ;
32
33
xsSlot * gif ;
33
34
PiuDimension gifWidth ;
@@ -82,11 +83,14 @@ const xsHostHooks ICACHE_FLASH_ATTR PiuGIFImageHooks = {
82
83
void PiuGIFImageBind (void * it , PiuApplication * application , PiuView * view )
83
84
{
84
85
PiuGIFImage * self = it ;
85
- if ((* self )-> path ) {
86
+ if ((* self )-> path || ( * self ) -> buffer ) {
86
87
xsBeginHost ((* self )-> the );
87
88
xsVars (2 );
88
89
xsVar (0 ) = xsReference ((* self )-> reference );
89
- xsVar (1 ) = * ((* self )-> path );
90
+ if ((* self )-> path )
91
+ xsVar (1 ) = * ((* self )-> path );
92
+ else
93
+ xsVar (1 ) = xsReference ((* self )-> buffer );
90
94
xsResult = xsCall2 (xsVar (0 ), xsID_load , xsVar (1 ), ((* self )-> flags & piuColorized ) ? xsTrue : xsFalse );
91
95
(* self )-> gif = xsToReference (xsResult );
92
96
(* self )-> gifWidth = xsToInteger (xsGet (xsResult , xsID_width ));
@@ -106,6 +110,11 @@ void PiuGIFImageDictionary(xsMachine* the, void* it)
106
110
xsSlot * path = PiuString (xsResult );
107
111
(* self )-> path = path ;
108
112
}
113
+ else
114
+ if (xsFindResult (xsArg (1 ), xsID_buffer )) {
115
+ xsSlot * buffer = xsToReference (xsResult );
116
+ (* self )-> buffer = buffer ;
117
+ }
109
118
if (xsFindResult (xsArg (1 ), xsID_color )) {
110
119
PiuColorRecord color ;
111
120
PiuColorDictionary (the , & xsResult , & color );
@@ -151,7 +160,10 @@ void PiuGIFImageMark(xsMachine* the, void* it, xsMarkRoot markRoot)
151
160
{
152
161
PiuGIFImage self = it ;
153
162
PiuContentMark (the , it , markRoot );
154
- PiuMarkString (the , self -> path );
163
+ if (self -> path )
164
+ PiuMarkString (the , self -> path );
165
+ if (self -> buffer )
166
+ PiuMarkReference (the , self -> buffer );
155
167
PiuMarkReference (the , self -> gif );
156
168
}
157
169
0 commit comments