static void embed_swf(SWFMovie movie, char* filename) { SWFPrebuiltClip builtclip; SWFDisplayItem it; char *name; SWFInput in; FILE *swf; if (!(swf = fopen (filename, "rb"))) { fprintf (stdout, "%s: %s\n", filename, strerror (errno)); exit(1); } if (!(in = newSWFInput_file(swf))) { fprintf (stdout, "Can't create SWFInput from file\n"); exit(1); } builtclip = newSWFPrebuiltClip_fromInput(in); if ( ! builtclip ) { fprintf (stdout, "Error creating prebuilt clip\n"); exit(1); } it = SWFMovie_add(mo, (SWFBlock)builtclip); name = base_name(filename); SWFDisplayItem_setName(it, name); free(name); }
SWFDBLBitmap newSWFDBLBitmap(FILE* f) { SWFDBLBitmap dbl = newSWFDBLBitmap_fromInput(newSWFInput_file(f)); BLOCK(dbl)->dtor = (destroySWFBlockMethod) destroySWFDBLBitmap_andInputs; return dbl; }
SWFSoundStream newSWFSoundStream(FILE* file) { SWFSoundStream s = newSWFSoundStream_fromInput(newSWFInput_file(file)); s->freeInput = TRUE; return s; }
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 mhsp_SWFBitmap(HSPEXINFO *hei, int p2, int p3, int p4) { FILE *fp1, *fp2; char filename[MHSP_STRMAX], alpha[MHSP_STRMAX]; SWFInput input; SWFBitmap *p1; lstrcpy(funcname, "SWFBitmap"); p1 = (SWFBitmap *)hei->HspFunc_prm_getv(); lstrcpyn(filename, hei->HspFunc_prm_gets(), MHSP_STRMAX); lstrcpyn(alpha, hei->HspFunc_prm_getds(""), MHSP_STRMAX); fp1 = fopen(filename, "rb"); if (!fp1) { return 1; } input = newSWFInput_file(fp1); fp2 = fopen(alpha, "rb"); if (fp2 && isJPEG(input)) { SWFInput_seek(input, 0, SEEK_SET); *p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_file(fp2)); } #ifdef JAMING else if (isDBL(input) || isJPEG(input)) #else else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input)) #endif { SWFInput_seek(input, 0, SEEK_SET); *p1 = newSWFBitmap_fromInput(input); } else { return -1; /* 非対応フォーマット */ } if (!mhsp_bitmap) { mhsp_bitmap = *p1; } return 0; }
SWFDBLBitmap newSWFDBLBitmap(FILE* f) { SWFInput input = newSWFInput_file(f); SWFDBLBitmap dbl = NULL; /* If newSWFInput_file() failed, return NULL to signify this */ if (NULL == input) return NULL; dbl = newSWFDBLBitmap_fromInput(input); /* If newSWFDBLBitmap_fromInput() failed, return NULL to signify this */ if (NULL == dbl) return NULL; BLOCK(dbl)->dtor = (destroySWFBlockMethod) destroySWFDBLBitmap_andInputs; return dbl; }
int main(int argc, char **argv) { SWFMovie mo; SWFInput in; SWFBitmap bitmap; SWFShape shpSmt; SWFShape shpHrd; SWFMovieClip mc; SWFDisplayItem it; int swfversion; SWFFont font; SWFMovieClip dejagnuclip; char outputFilename[256]; FILE* imgfile; if ( argc < 2 ) { fprintf(stderr, "Usage: %s <swf_version>\n", argv[0]); exit(EXIT_FAILURE); } swfversion = atoi(argv[1]); sprintf(outputFilename, "BitmapSmoothingTest-v%d.swf", swfversion); /********************************************* * * Initialization * *********************************************/ puts("Setting things up"); Ming_init(); Ming_useSWFVersion (swfversion); mo = newSWFMovieWithVersion(swfversion); /**************************************************** * Create filled shapes mc ****************************************************/ imgfile = fopen(MEDIADIR"/vstroke.png", "rb"); if (!imgfile) { fprintf(stderr, "Failed to open bitmap file"); return EXIT_FAILURE; } // Note that recent ming version have the more convenient // newSWFInput_filename() function, but we want to support // older versions. in = newSWFInput_file(imgfile); bitmap = newSWFBitmap_fromInput(in); if (!bitmap) { return EXIT_FAILURE; } shpSmt = newSWFShapeFromBitmap(bitmap, SWFFILL_CLIPPED_BITMAP); shpHrd = newSWFShapeFromBitmap(bitmap, SWFFILL_NONSMOOTHED_CLIPPED_BITMAP); mc = newSWFMovieClip(); SWFMovieClip_add(mc, (SWFBlock)shpSmt); it = SWFMovieClip_add(mc, (SWFBlock)shpHrd); SWFDisplayItem_moveTo(it, 0, 5); SWFMovieClip_nextFrame(mc); /**************************************************** * Create filled shapes mc, and scale it ****************************************************/ it = SWFMovie_add(mo, (SWFBlock)mc); SWFDisplayItem_scaleTo(it, 30, 10); SWFMovie_setDimension(mo, SWFBitmap_getWidth(bitmap)*30, 500); /**************************************************** * Add dejagnu clip ****************************************************/ font = get_default_font(MEDIADIR); dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 200, 200); it = SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFDisplayItem_setDepth(it, 200); SWFDisplayItem_move(it, 0, 100); /**************************************************** * TODO: Add actions ****************************************************/ /**************************************************** * Save things up ****************************************************/ printf("Saving %s\n", outputFilename); SWFMovie_nextFrame(mo); /* showFrame */ SWFMovie_save(mo, outputFilename); fclose(imgfile); return EXIT_SUCCESS; }