void DefineEditTextTag::read(SWFStream& in, movie_definition& m) { _rect = readRect(in); in.align(); in.ensureBytes(2); int flags = in.read_u8(); _hasText = flags & (1 << 7); _wordWrap = flags & (1 << 6); _multiline = flags & (1 << 5); _password = flags & (1 << 4); _readOnly = flags & (1 << 3); const bool hasColor = flags & (1 << 2); const bool hasMaxChars = flags & (1 << 1); const bool hasFont = flags & (1 << 0); flags = in.read_u8(); // 0: no font class, 1 font class and height, can't be true if has_font was true bool hasFontClass = flags & (1 << 7); if (hasFontClass && hasFont ) { IF_VERBOSE_MALFORMED_SWF( log_swferror("DefineEditText: hasFontClass can't be true if " "hasFont is true, ignoring"); );
rgba readRGBA(SWFStream& in) { in.ensureBytes(4); const boost::uint8_t r = in.read_u8(); const boost::uint8_t g = in.read_u8(); const boost::uint8_t b = in.read_u8(); const boost::uint8_t a = in.read_u8(); return rgba(r, g, b, a); }
rgba readRGB(SWFStream& in) { in.ensureBytes(3); const std::uint8_t r = in.read_u8(); const std::uint8_t g = in.read_u8(); const std::uint8_t b = in.read_u8(); const std::uint8_t a = 0xff; return rgba(r, g, b, a); }
// Create and initialize a sprite, and add it to the movie. void sprite_loader(SWFStream& in, TagType tag, movie_definition& m, const RunResources& r) { assert(tag == SWF::DEFINESPRITE); // 39 - DefineSprite in.ensureBytes(2); const boost::uint16_t id = in.read_u16(); IF_VERBOSE_PARSE( log_parse(_(" sprite: char id = %d"), id); );
void DefineText2Tag::loader(SWFStream& in, TagType tag, movie_definition& m, const RunResources& /*r*/) { assert(tag == DEFINETEXT2); in.ensureBytes(2); boost::uint16_t id = in.read_u16(); std::auto_ptr<DefineTextTag> t(new DefineTextTag(in, m, tag)); IF_VERBOSE_PARSE( log_parse(_("Text DisplayObject, id = %d"), id); );
// read placeObject2 actions void PlaceObject2Tag::readPlaceActions(SWFStream& in) { const int movie_version = _movie_def.get_version(); in.ensureBytes(2); std::uint16_t reserved = in.read_u16(); IF_VERBOSE_MALFORMED_SWF( if (reserved != 0) { log_swferror(_("Reserved field in PlaceObject actions == " "%u (expected 0)"), reserved); } );
void DefineMorphShapeTag::read(SWFStream& in, TagType tag, movie_definition& md, const RunResources& r) { assert(tag == DEFINEMORPHSHAPE || tag == DEFINEMORPHSHAPE2 || tag == DEFINEMORPHSHAPE2_); const SWFRect bounds1 = readRect(in); const SWFRect bounds2 = readRect(in); if (tag == DEFINEMORPHSHAPE2 || tag == DEFINEMORPHSHAPE2_) { // TODO: Use these values. const SWFRect innerBound1 = readRect(in); const SWFRect innerBound2 = readRect(in); UNUSED(innerBound1); UNUSED(innerBound2); // This should be used -- first 6 bits reserved, then // 'non-scaling' stroke, then 'scaling' stroke -- these can be // used to optimize morphing. in.ensureBytes(1); static_cast<void>(in.read_u8()); } in.ensureBytes(4); // Offset. What is this for? static_cast<void>(in.read_u32()); // Next line will throw ParserException on malformed SWF const boost::uint16_t fillCount = in.read_variable_count(); for (size_t i = 0; i < fillCount; ++i) { OptionalFillPair fp = readFills(in, tag, md, true); _shape1.addFillStyle(fp.first); _shape2.addFillStyle(*fp.second); } const boost::uint16_t lineCount = in.read_variable_count(); LineStyle ls1, ls2; for (size_t i = 0; i < lineCount; ++i) { ls1.read_morph(in, tag, md, r, &ls2); _shape1.addLineStyle(ls1); _shape2.addLineStyle(ls2); } _shape1.read(in, tag, md, r); in.align(); _shape2.read(in, tag, md, r); // Set bounds as read in *this* tags rather then // the one computed from ShapeRecord parser // (does it make sense ?) _shape1.setBounds(bounds1); _shape2.setBounds(bounds2); // Starting bounds are the same as shape1 _bounds = bounds1; assert(_shape1.fillStyles().size() == _shape2.fillStyles().size()); assert(_shape1.lineStyles().size() == _shape2.lineStyles().size()); }