void printShape(FILE *f, int length, SWFBlocktype type) { int start = fileOffset; int fillBits, lineBits; println("ShapeID: %i", readUInt16(f)); print("Bounds: "); printRect(f); putchar('\n'); putchar('\n'); printFillStyleArray(f, type); printLineStyleArray(f, type); putchar('\n'); byteAlign(); fillBits = readBits(f,4); lineBits = readBits(f,4); while(fileOffset < length+start && printShapeRec(f, &lineBits, &fillBits, type)) ; /* go for end tag.. if(fileOffset == length+start && bufbits > 5) printShapeRec(f, &lineBits, &fillBits, type); */ putchar('\n'); }
void printDefineShape(struct Shape *shape, int id, int isMorph) { int i; for(i=0; i<shape->fills.nFills; ++i) printFillStyle(&(shape->fills.fill[i]), id, i+1, isMorph); for(i=0; i<shape->shapes.nShapes; ++i) printShapeRec(shape, &(shape->shapes.shape[i]), id); }
void printMorphShape(FILE *f, int length) { int offset, start = fileOffset; int fillBits, lineBits, here; println("ShapeID: %i", readUInt16(f)); print("Bounds1: "); printRect(f); putchar('\n'); print("Bounds2: "); printRect(f); putchar('\n'); offset = readUInt32(f); println("(%i)\toffset = %i", fileOffset, offset); here = fileOffset; printFillStyleArray(f, SWF_DEFINEMORPHSHAPE); printLineStyleArray(f, SWF_DEFINEMORPHSHAPE); fillBits = readBits(f, 4); lineBits = readBits(f, 4); putchar('\n'); println("Shape1:"); while(fileOffset < here+offset) printShapeRec(f, &lineBits, &fillBits, SWF_DEFINESHAPE3); byteAlign(); /* ??? */ fillBits = readBits(f, 4); lineBits = readBits(f, 4); putchar('\n'); println("Shape2:"); while(fileOffset < start+length) printShapeRec(f, &lineBits, &fillBits, SWF_DEFINESHAPE3); }
void printDefineFont(FILE *f, int length) { int here, off0, off, i, nShapes, fillBits=1, lineBits=1; int *offset; println("FontID: %i", readUInt16(f)); off0 = readUInt16(f); nShapes = off0/2; println("Number of shapes: %i", nShapes); offset = (int *)malloc(nShapes*sizeof(int)); ++gIndent; println("Offset0: 0"); for(i=1; i<nShapes; ++i) { off = readUInt16(f); offset[i-1] = off-off0; println("Offset%i: %i", i, offset[i-1]); } offset[nShapes-1] = length-2-(nShapes*2); here = fileOffset; for(i=0; i<nShapes; ++i) { putchar('\n'); byteAlign(); println("Shape %i:", i); fillBits = readBits(f, 4); lineBits = readBits(f, 4); ++gIndent; while(fileOffset < here+offset[i]) printShapeRec(f, &fillBits, &lineBits, 2); --gIndent; } --gIndent; }
void printDefineFont2(FILE *f, int length) { int flags, nGlyphs, namelen, i, fillBits, lineBits; int here = fileOffset; int *offset; println("fontID: %i", readUInt16(f)); flags = readUInt8(f); readUInt8(f); /* "reserved" */ namelen = readUInt8(f); print("Font Name: "); for(; namelen>0; --namelen) putchar((unsigned char)readUInt8(f)); putchar('\n'); nGlyphs = readUInt16(f); println("number of glyphs: %i\n", nGlyphs); offset = (unsigned int *)malloc(nGlyphs*sizeof(int)); /* offset table */ here = fileOffset; for(i=0; i<=nGlyphs; ++i) { if(flags & FONTINFO2_WIDEOFFSETS) offset[i] = readUInt32(f)-4*nGlyphs-2; else offset[i] = readUInt16(f)-2*nGlyphs-2; println("Offset%i: %i", i, offset[i]); } here = fileOffset; /* shape table */ for(i=0; i<nGlyphs; ++i) { byteAlign(); println("Glyph %i:", i); fillBits = readBits(f, 4); lineBits = readBits(f, 4); byteAlign(); while(printShapeRec(f, &fillBits, &lineBits, 2)) ; putchar('\n'); } /* code table */ for(i=0; i<nGlyphs; ++i) { if(flags & FONTINFO2_WIDECODES) println("glyph code %i: %i", i, readUInt16(f)); else println("glyph code %i: %i", i, readUInt8(f)); } if(flags & FONTINFO2_HASLAYOUT) { int kernCount, code1, code2; println("ascender height: %i", readSInt16(f)); println("descender height: %i", readSInt16(f)); println("leading height: %i", readSInt16(f)); for(i=0; i<nGlyphs; ++i) printf("\tadvance %i: %i\n", i, readSInt16(f)); for(i=0; i<nGlyphs; ++i) { print("bounds %i: ", i); printRect(f); putchar('\n'); } kernCount = readUInt16(f); for(i=0; i<kernCount; ++i) { code1 = (flags & FONTINFO2_WIDECODES) ? readUInt16(f) : readUInt8(f); code2 = (flags & FONTINFO2_WIDECODES) ? readUInt16(f) : readUInt8(f); println("(%i,%i): adjustment = %i", code1, code2, readSInt16(f)); } } }