📄 script.cc
字号:
// Get each of the colors. for (U16 j = 0; j < nbGradients; j++) { GetByte(); GetByte(); GetByte(); GetByte(); if (getAlpha) { GetByte(); } } } else if (fillStyle & 0x40) { type = (FillType) (fillStyle & 0x41); // Get the bitmapId GetWord(); // Get the bitmap matrix. GetMatrix(&matrix); } else { type = (FillType) 0; // A solid color GetByte(); GetByte(); GetByte(); if (getAlpha) { GetByte(); } /* printf("fillstyle: %x %x %x %x\n", defs[i].color.red, defs[i].color.green, defs[i].color.blue, defs[i].color.alpha); */ } }}void CInputScript::ParseLineStyle(long getAlpha){ long i; // Get the number of lines. U16 nLines = GetByte(); // Do we have a larger number? if (nLines == 255) { // Get the larger number. nLines = GetWord(); } // Get each of the line styles. for (i = 0; i < nLines; i++) { GetWord(); GetByte(); GetByte(); GetByte(); if (getAlpha) { GetByte(); } }}void CInputScript::ParseDefineShape(int level){ Shape *shape; Rect rect; U32 tagid; tagid = (U32) GetWord(); shape = new Shape(tagid,level); if (shape == NULL) { outOfMemory = 1; return; } shape->dict = this; // Get the frame information. GetRect(&rect); shape->setBoundingBox(rect); shape->file_ptr = (unsigned char*)malloc(m_tagEnd-m_filePos); if (shape->file_ptr == NULL) { outOfMemory = 1; delete shape; return; } memcpy((void*)shape->file_ptr,(void*)&m_fileBuf[m_filePos], m_tagEnd-m_filePos); shape->getStyles = 1; shape->getAlpha = (level == 3); ParseShapeData(level == 3, 1); addCharacter(shape);}void CInputScript::S_DumpImageGuts(){#if 0 U32 lfCount = 0; printf("----- dumping image details -----"); while (m_filePos < m_tagEnd) { if ((lfCount % 16) == 0) { fprintf(stdout, "\n"); } lfCount += 1; fprintf(stdout, "%02x ", GetByte()); } fprintf(stdout, "\n");#endif}void CInputScript::ParseDefineBits(){ Bitmap *bitmap; U32 tagid = (U32) GetWord(); int status; bitmap = new Bitmap(tagid,1); if (bitmap == NULL) { outOfMemory = 1; return; } status = bitmap->buildFromJpegAbbreviatedData(&m_fileBuf[m_filePos]); if (status < 0) { fprintf(stderr,"Unable to read JPEG data\n"); delete bitmap; return; } addCharacter(bitmap);}void CInputScript::ParseDefineBitsJPEG2(){ Bitmap *bitmap; U32 tagid = (U32) GetWord(); int status; bitmap = new Bitmap(tagid,2); if (bitmap == NULL) { outOfMemory = 1; return; } status = bitmap->buildFromJpegInterchangeData(&m_fileBuf[m_filePos], 0, 0); if (status < 0) { fprintf(stderr,"Unable to read JPEG data\n"); delete bitmap; return; } addCharacter(bitmap);}void CInputScript::ParseDefineBitsJPEG3(){ Bitmap *bitmap; U32 tagid = (U32) GetWord(); int status; long offset; printf("tagDefineBitsJPEG3 \ttagid %-5u\n", tagid); bitmap = new Bitmap(tagid,3); if (bitmap == NULL) { outOfMemory = 1; return; } offset = GetDWord(); // Not in the specs !!!! status = bitmap->buildFromJpegInterchangeData(&m_fileBuf[m_filePos], 1, offset); if (status < 0) { fprintf(stderr,"Unable to read JPEG data\n"); delete bitmap; return; } addCharacter(bitmap);}void CInputScript::ParseDefineBitsLossless(int level){ Bitmap *bitmap; U32 tagid = (U32) GetWord(); int status; int tableSize; bitmap = new Bitmap(tagid,0); if (bitmap == NULL) { outOfMemory = 1; return; } int format = GetByte(); int width = GetWord(); int height = GetWord(); tableSize = 0; if (format == 3) { tableSize = GetByte(); } status = bitmap->buildFromZlibData(&m_fileBuf[m_filePos], width, height, format, tableSize, level == 2); if (status < 0) { fprintf(stderr,"Unable to read ZLIB data\n"); delete bitmap; return; } addCharacter(bitmap);}void CInputScript::ParseJPEGTables(){ Bitmap::readJpegTables(&m_fileBuf[m_filePos]);}ButtonRecord * CInputScript::ParseButtonRecord(long getCxform){ U16 state; ButtonRecord *br; long tagid; Matrix matrix; long layer; Cxform *cxform; state = (U16) GetByte(); if (state == 0) return 0; br = new ButtonRecord; if (br == NULL) { outOfMemory = 1; return 0; } tagid = GetWord(); layer = GetWord(); GetMatrix(&matrix); if (br) { br->state = (ButtonState) state; br->character = getCharacter(tagid); br->layer = layer; br->cxform = 0; br->buttonMatrix = matrix; } if (getCxform) { cxform = new Cxform; GetCxform(cxform, true); if (br) { br->cxform = cxform; if (cxform == NULL) { outOfMemory = 1; } } } return br;}ActionRecord * CInputScript::ParseActionRecord(){ U8 action; U16 length = 0; char *url, *target, *label; long frameIndex, skipCount; ActionRecord *ar; action = GetByte(); if (action == 0) return 0; ar = new ActionRecord; if (ar == NULL) { outOfMemory = 1; return 0; } ar->action = (Action)action; if (action & 0x80) { length = GetWord(); } switch (action) { case ActionGotoFrame: frameIndex = GetWord(); if (ar) { ar->frameIndex = frameIndex; } break; case ActionGetURL: url = GetString(); target = GetString(); if (ar) { ar->url = strdup(url); ar->target = strdup(target); } break; case ActionWaitForFrame: frameIndex = GetWord(); skipCount = GetByte(); if (ar) { ar->frameIndex = frameIndex; ar->skipCount = skipCount; } break; case ActionSetTarget: target = strdup(GetString()); if (ar) { ar->target = target; } break; case ActionGoToLabel: label = GetString(); if (ar) { ar->frameLabel = strdup(label); } break; default: while (length--) { GetByte(); } break; } return ar;}void CInputScript::ParseDefineButton(){ Button *button; ButtonRecord *buttonRecord; ActionRecord *actionRecord; U32 tagid = (U32) GetWord(); button = new Button(tagid); if (button == NULL) { outOfMemory = 1; return; } do { buttonRecord = ParseButtonRecord(); if (buttonRecord) { button->addButtonRecord( buttonRecord ); } if (outOfMemory) { return; } } while (buttonRecord); do { actionRecord = ParseActionRecord(); if (actionRecord) { button->addActionRecord( actionRecord ); } if (outOfMemory) { return; } } while (actionRecord); addCharacter(button);}void CInputScript::ParseDefineButton2(){ Button *button; ButtonRecord *buttonRecord; ActionRecord *actionRecord; U16 transition; U16 offset; U8 menu; U32 tagid = (U32) GetWord(); button = new Button(tagid); if (button == NULL) { outOfMemory = 1; return; } menu = GetByte(); offset = GetWord(); do { buttonRecord = ParseButtonRecord(true); if (buttonRecord) { button->addButtonRecord( buttonRecord ); } if (outOfMemory) { return; } } while (buttonRecord); while (offset) { offset = GetWord(); transition = GetWord(); do { actionRecord = ParseActionRecord(); if (actionRecord) { button->addActionRecord( actionRecord ); } if (outOfMemory) { return; } } while (actionRecord); button->addCondition( transition ); } addCharacter(button);}void CInputScript::ParseDefineFont(){ SwfFont *font = 0; U32 tagid = (U32) GetWord(); long start; long nb,n; long offset; long *offsetTable = 0; Shape *shapes = 0; font = new SwfFont(tagid); if (font == NULL) { outOfMemory = 1; return; } start = m_filePos; offset = GetWord(); nb = offset/2; offsetTable = new long[nb]; if (offsetTable == NULL) { goto memory_error; } offsetTable[0] = offset; for(n=1; n<nb; n++) { offsetTable[n] = GetWord(); } shapes = new Shape[nb]; if (shapes == NULL) { goto memory_error; } for(n=0; n<nb; n++) { long here; m_filePos = offsetTable[n]+start; here = m_filePos; ParseShapeData(0, 0); // Keep data for later parsing shapes[n].file_ptr = (unsigned char*)malloc(m_filePos-here); if (shapes[n].file_ptr == NULL) { goto memory_error; } memcpy((void*)shapes[n].file_ptr,(void*)&m_fileBuf[here],m_filePos-here); } font->setFontShapeTable(shapes,nb); delete[] offsetTable; addCharacter(font); return;memory_error: outOfMemory = 1; if (offsetTable) delete offsetTable; if (font) delete font; if (shapes) delete[] shapes;}void CInputScript::ParseDefineMorphShape(){ U32 tagid = (U32) GetWord(); tagid = tagid; printf("tagDefineMorphShape \ttagid %-5u\n", tagid);}void CInputScript::ParseDefineFontInfo(){ SwfFont *font; U32 tagid = (U32) GetWord(); long nameLen; char *name; long n,nb; FontFlags flags; long *lut; font = (SwfFont *)getCharacter(tagid); if (font == NULL) { outOfMemory = 1; return; } nameLen = GetByte(); name = new char[nameLen+1]; if (name == NULL) { outOfMemory = 1; return; } for(n=0; n < nameLen; n++) { name[n] = GetByte(); } name[n]=0; font->setFontName(name); delete name; flags = (FontFlags)GetByte(); font->setFontFlags(flags); nb = font->getNbGlyphs(); lut = new long[nb]; if (lut == NULL) { outOfMemory = 1; delete font; return; } for(n=0; n < nb; n++) { if (flags & fontWideCodes) { lut[n] = GetWord(); } else { lut[n] = GetByte(); } } font->setFontLookUpTable(lut);}void CInputScript::ParseDefineFont2(){ int n; U32 tagid = (U32) GetWord(); FontFlags flags; char *name; long nameLen; long fontGlyphCount; long *offsetTable = NULL; Shape *shapes = NULL; long start; SwfFont *font; long *lut = NULL; font = new SwfFont(tagid); if (font == NULL) { goto memory_error; } flags = (FontFlags)GetWord(); font->setFontFlags(flags); nameLen = GetByte(); name = new char[nameLen+1]; if (name == NULL) { goto memory_error; } for(n=0; n < nameLen; n++) { name[n] = GetByte(); } name[n]=0; font->setFontName(name); delete name; fontGlyphCount = GetWord(); start = m_filePos; offsetTable = new long[fontGlyphCount]; if (offsetTable == NULL) { goto memory_error; } for (n=0; n<fontGlyphCount; n++) { if (flags & 8) { offsetTable[n] = GetDWord(); } else { offsetTable[n] = GetWord(); } } shapes = new Shape[fontGlyphCount]; if (shapes == NULL) { goto memory_error; } for (n=0; n<fontGlyphCount; n++) { long here; m_filePos = offsetTable[n]+start; here = m_filePos; ParseShapeData(0, 0); // Keep data for later parsing shapes[n].file_ptr = (unsigned char*)malloc(m_filePos-here); if (shapes[n].file_ptr == NULL) { goto memory_error; } memcpy((void*)shapes[n].file_ptr,(void*)&m_fileBuf[here],m_filePos-here); } font->setFontShapeTable(shapes,fontGlyphCount); lut = new long[fontGlyphCount]; if (lut == NULL) { goto memory_error; } for(n=0; n < fontGlyphCount; n++) { if (flags & 4) { lut[n] = GetWord(); } else { lut[n] = GetByte(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -