1 /* gcc -Wall `pkg-config --libs --cflags libming glib-2.0` blend-mode.c -o blend-mode && ./blend-mode
9 const char *modes
[] = {
29 create_yellow_image (guint w
, guint h
)
35 data
= g_malloc (w
* h
* 4);
36 for (y
= 0; y
< h
; y
++) {
37 /* get 15 steps of 10 pixel high lines fading in yellow */
38 guint32 pixel
= 255 / 15 * (y
* 16 / h
);
40 for (x
= 0; x
< w
; x
++) {
41 data
[y
* w
+ x
] = pixel
;
44 ret
= newSWFBitmap_fromData ((guint8
*) data
, w
, h
, TRUE
);
50 create_teal_image (guint w
, guint h
)
56 data
= g_malloc (w
* h
* 4);
57 for (y
= 0; y
< h
; y
++) {
58 /* get 15 steps of 10 pixel high lines fading in yellow */
59 for (x
= 0; x
< w
; x
++) {
60 guint32 pixel
= 255 / 15 * (x
* 16 / w
);
62 data
[y
* w
+ x
] = pixel
;
65 ret
= newSWFBitmap_fromData ((guint8
*) data
, w
, h
, TRUE
);
71 add_images (SWFMovie movie
, int blend_mode
)
78 clip
= newSWFMovieClip ();
80 bitmap
= create_yellow_image (SIZE
, SIZE
);
81 shape
= newSWFShapeFromBitmap (bitmap
, SWFFILL_CLIPPED_BITMAP
);
82 item
= SWFMovieClip_add (clip
, (SWFBlock
) shape
);
83 SWFDisplayItem_setDepth (item
, 1);
85 bitmap
= create_teal_image (SIZE
, SIZE
);
86 shape
= newSWFShapeFromBitmap (bitmap
, SWFFILL_CLIPPED_BITMAP
);
87 item
= SWFMovieClip_add (clip
, (SWFBlock
) shape
);
88 SWFDisplayItem_setDepth (item
, 2);
89 SWFDisplayItem_setBlendMode (item
, blend_mode
);
91 SWFMovieClip_nextFrame (clip
);
93 item
= SWFMovie_add (movie
, (SWFBlock
) clip
);
94 SWFDisplayItem_setBlendMode (item
, SWFBLEND_MODE_LAYER
);
100 do_movie (int version
)
106 for (mode
= 0; mode
< G_N_ELEMENTS (modes
); mode
++) {
107 movie
= newSWFMovieWithVersion (version
);
108 movie
= newSWFMovie();
109 SWFMovie_setRate (movie
, 1);
110 SWFMovie_setDimension (movie
, SIZE
, SIZE
);
111 SWFMovie_setBackground (movie
, 0, 0, 0);
113 add_images (movie
, mode
);
114 SWFMovie_nextFrame (movie
);
116 real_name
= g_strdup_printf ("blend-mode-%s-%d.swf", modes
[mode
], version
);
117 SWFMovie_save (movie
, real_name
);
123 main (int argc
, char **argv
)
130 for (i
= 7; i
< 9; i
++)