static void embed_image(SWFMovie movie, char *f) { SWFFill fill; SWFBitmap bm; SWFShape shape; SWFMovieClip clip; SWFDisplayItem it, it2; FILE *raster; SWFInput in; int height, width; char *name; if (!(raster = fopen (f, "rb"))) { fprintf (stdout, "%s: %s\n", f, strerror (errno)); exit(1); } if (!(in = newSWFInput_file(raster))) { fprintf (stdout, "Can't create SWFInput from file\n"); exit(1); } if (!(bm = newSWFBitmap_fromInput (in))) { fprintf (stdout, "Error creating bitmap"); exit(1); } height = SWFBitmap_getHeight(bm); width = SWFBitmap_getWidth(bm); shape = newSWFShape(); SWFShape_movePenTo(shape, 0, 0); fill = SWFShape_addBitmapFill(shape, bm, SWFFILL_CLIPPED_BITMAP); SWFShape_setRightFill(shape, fill); SWFShape_drawLineTo(shape, width, 0); SWFShape_drawLineTo(shape, width, height); SWFShape_drawLineTo(shape, 0, height); SWFShape_drawLineTo(shape, 0, 0); clip = newSWFMovieClip(); it2 = SWFMovieClip_add(clip, (SWFBlock)shape); SWFMovieClip_nextFrame(clip); it = SWFMovie_add(mo, (SWFBlock)clip); name = base_name(f); SWFDisplayItem_setName(it, name); free(name); }
EXPORT BOOL WINAPI s_addBitmapFill(HSPEXINFO *hei, int p2, int p3, int p4) { byte flags; SWFBitmap bitmap; SWFFill *p1; lstrcpy(funcname, "s_addBitmapFill"); p1 = (SWFFill *)hei->HspFunc_prm_getv(); bitmap = (SWFBitmap)hei->HspFunc_prm_geti(); flags = (byte)hei->HspFunc_prm_getdi(SWFFILL_TILED_BITMAP); *p1 = SWFShape_addBitmapFill(mhsp_shape, bitmap, flags); if (!mhsp_fill) { mhsp_fill = *p1; } return 0; }
int main(int argc, char *argv[]) { SWFMovie m; SWFShape shape; SWFBitmap b; SWFFill fill; SWFDisplayItem i; FILE *file_bitmap; float n; float height; float width; char *imageFile = "backyard.jpg"; Ming_init(argc, argv); Ming_useSWFVersion(5); m = newSWFMovie(); shape = newSWFShape(); if(!(file_bitmap = fopen(imageFile,"rb"))) { printf("Couldn't find file '%s'", imageFile); } b = (SWFCharacter) newSWFJpegBitmap(file_bitmap); SWFMovie_setDimension(m, SWFBitmap_getWidth(b), SWFBitmap_getHeight(b)); fill = SWFShape_addBitmapFill(shape, b, SWFFILL_TILED_BITMAP); SWFShape_setRightFill(shape, fill); height = (float) SWFBitmap_getHeight(b); width = (float) SWFBitmap_getWidth(b); SWFShape_drawLineTo(shape, width, 0.00); SWFShape_drawLineTo(shape, width, height); SWFShape_drawLineTo(shape, 0.00, height); SWFShape_drawLineTo(shape, 0.00, 0.00); i = SWFMovie_add(m, (SWFBlock) shape); for(n=0; n<20.0; ++n) { SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0); SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0); SWFMovie_nextFrame(m); } for(n=20.0; n>0; --n) { SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0); SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0); SWFMovie_nextFrame(m); } SWFMovie_save(m, "cxform.swf"); fclose(file_bitmap); /* Do not close earlier or an error will happen */ return 0; }