void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, float scaley, int scalepos) { if(movex || movey || scalex != 1.0 || scaley != 1.0) { switch(tag->id) { case ST_PLACEOBJECT2: { MATRIX m; U8 flags; swf_GetMatrix(0, &m); tag->pos = 0; tag->readBit = 0; flags = swf_GetU8(tag); swf_SetU8(output, flags|4); swf_SetU16(output, swf_GetU16(tag)); //depth //flags&1: move if(flags&2) { swf_SetU16(output, swf_GetU16(tag)); //id } // flags & 4 if(flags&4) { swf_GetMatrix(tag, &m); } else { swf_GetMatrix(0, &m); } matrix_adjust(&m, movex, movey, scalex, scaley, scalepos); swf_SetMatrix(output, &m); if (tag->readBit) { tag->pos++; tag->readBit = 0; } //swf_ResetReadBits(tag); swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos); break; } case ST_PLACEOBJECT: { MATRIX m; swf_SetU16(output, swf_GetU16(tag)); //id swf_SetU16(output, swf_GetU16(tag)); //depth swf_GetMatrix(tag, &m); matrix_adjust(&m, movex, movey, scalex, scaley, scalepos); swf_SetMatrix(output, &m); if (tag->readBit) { tag->pos++; tag->readBit = 0; } //swf_ResetReadBits(tag); swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos); break; } default: swf_SetBlock(output, tag->data, tag->len); } } else { swf_SetBlock(output, tag->data, tag->len); } }
static void write_font(SWFFONT * font, char *filename) { SWF swf; TAG *t; SRECT r; RGBA rgb; int f; int useDefineFont2 = 1; int storeGlyphNames = 1; #define WRITEFONTID 8888 font->id = WRITEFONTID; memset(&swf, 0x00, sizeof(SWF)); swf.fileVersion = 9; swf.frameRate = 0x4000; t = swf_InsertTag(NULL, ST_SETBACKGROUNDCOLOR); swf.firstTag = t; rgb.r = 0xef; rgb.g = 0xef; rgb.b = 0xff; swf_SetRGB(t, &rgb); t = swf_InsertTag(t, ST_DEFINEFONT3); swf_FontSetDefine2(t, font); t = swf_InsertTag(t, ST_DEFINEFONTALIGNZONES); swf_SetU16(t, font->id); swf_SetU8(t, 0); //thin int i; for(i=0;i<256;i++) { swf_SetU8(t, 2); swf_SetF16(t, 82.0 / 1024.0); swf_SetF16(t, 82.0 / 1024.0); swf_SetF16(t, ((i%16/2)*82.0) / 1024.0); swf_SetF16(t, ((i/16/2)*82.0) / 1024.0); /* if(i<128 && (i&15)<8) { swf_SetF16(t, 0.0); swf_SetF16(t, 0.0); swf_SetF16(t, 640.0 / 1024.0); swf_SetF16(t, 640.0 / 1024.0); } else if(i<128 && (i&15)>=8) { swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 330.0 / 1024.0); swf_SetF16(t, 640.0 / 1024.0); } else if(i>=128 && (i&15)<8) { swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 640.0 / 1024.0); swf_SetF16(t, 330.0 / 1024.0); } else { swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 0.0 / 1024.0); swf_SetF16(t, 330.0 / 1024.0); swf_SetF16(t, 330.0 / 1024.0); }*/ swf_SetU8(t, 3); // x and y } int s; int xmax = 0; int ymax = 0; int ypos = 1; U8 gbits, abits; int x, y, c; int range = font->maxascii; c = 0; range = 256; xmax = 1280; ymax = 1280*20; swf.movieSize.xmax = xmax * 20; swf.movieSize.ymax = ymax; t = swf_InsertTag(t, ST_DEFINETEXT); swf_SetU16(t, font->id + 1); // ID r.xmin = 0; r.ymin = 0; r.xmax = swf.movieSize.xmax; r.ymax = swf.movieSize.ymax; swf_SetRect(t, &r); swf_SetMatrix(t, NULL); abits = swf_CountBits(xmax * 16, 0); gbits = 8; swf_SetU8(t, gbits); swf_SetU8(t, abits); rgb.r = 0x00; rgb.g = 0x00; rgb.b = 0x00; ypos = 2; int textscale = 1024; for (y = 0; y < ((range + 15) / 16); y++) { for (x = 0; x < 16; x++) { //swf_TextSetInfoRecord(t, font, textscale, &rgb, x*64*20+64*20+10+(x+y)*20, y*64*20+128*20+10+(x^y)*20); swf_TextSetInfoRecord(t, font, textscale, &rgb, x*64*20+64*20+10, y*64*20+128*20+10); int g = y * 16 + x; swf_SetU8(t, 1); swf_SetBits(t, g, gbits); swf_SetBits(t, 0, abits); swf_ResetWriteBits(t); } } swf_SetU8(t, 0); t = swf_InsertTag(t, ST_CSMTEXTSETTINGS); swf_SetU16(t, font->id + 1); swf_SetU8(t, (1<<3)//grid |0x40//flashtype ); swf_SetU32(t, 0x20000);//thickness swf_SetU32(t, 0x800000);//sharpness swf_SetU8(t, 0);//reserved t = swf_InsertTag(t, ST_PLACEOBJECT2); swf_ObjectPlace(t, font->id + 1, 1, NULL, NULL, NULL); t = swf_InsertTag(t, ST_SHOWFRAME); t = swf_InsertTag(t, ST_END); f = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0644); if FAILED (swf_WriteSWF(f, &swf)) fprintf(stderr, "WriteSWF() failed in writeFont().\n"); close(f); swf_FreeTags(&swf); }