예제 #1
0
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");
		);
예제 #2
0
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);
}
예제 #3
0
파일: TypesParser.cpp 프로젝트: aopui/gnash
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);
}
예제 #4
0
// 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);
    );
예제 #5
0
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);
    );
예제 #6
0
// 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);
        }
    );
예제 #7
0
파일: TypesParser.cpp 프로젝트: aopui/gnash
/// Format of the bit-packed rectangle is:
///
/// bits  | name  | description
/// ------+-------+-------------------------
///   5   | nbits | number of bits used in subsequent values
/// nbits | xmin  | minimum X value
/// nbits | xmax  | maximum X value
/// nbits | ymin  | minimum Y value
/// nbits | ymax  | maximum Y value
///
/// If max values are less then min values the SWF is malformed;
/// in this case this method will raise an swf_error and set the
/// rectangle to the NULL rectangle. See is_null().
SWFRect
readRect(SWFStream& in)
{
    in.align();
    in.ensureBits(5);
    const int nbits = in.read_uint(5);

    int minx = 0, maxx = 0, miny = 0, maxy = 0;
    
    if (nbits > 0) {
       in.ensureBits(nbits*4);
       minx = in.read_sint(nbits);
       maxx = in.read_sint(nbits);
       miny = in.read_sint(nbits);
       maxy = in.read_sint(nbits);
    }

    // Check if this SWFRect is valid.
    if (maxx < minx || maxy < miny) {
        // We set invalid rectangles to NULL, but we might instead
        // want to actually swap the values if the proprietary player
        // does so. TODO: check it out.
        IF_VERBOSE_MALFORMED_SWF(
            log_swferror(_("Invalid rectangle: "
                           "minx=%g maxx=%g miny=%g maxy=%g"), minx, maxx, miny, maxy);
        );
예제 #8
0
SWFMatrix
readSWFMatrix(SWFStream& in)
{
    in.align();

    in.ensureBits(1);
    const bool has_scale = in.read_bit(); 

    boost::int32_t sx = 65536;
    boost::int32_t sy = 65536;
    if (has_scale) {
        in.ensureBits(5);
        const boost::uint8_t scale_nbits = in.read_uint(5);
        in.ensureBits(scale_nbits * 2);
        sx = in.read_sint(scale_nbits);
        sy = in.read_sint(scale_nbits);
    }

    in.ensureBits(1);
    const bool has_rotate = in.read_bit();
    boost::int32_t shx = 0;
    boost::int32_t shy = 0;
    if (has_rotate) {
        in.ensureBits(5);
        int rotate_nbits = in.read_uint(5);

        in.ensureBits(rotate_nbits * 2);
        shx = in.read_sint(rotate_nbits);
        shy = in.read_sint(rotate_nbits);
    }

    in.ensureBits(5);
    const boost::uint8_t translate_nbits = in.read_uint(5);
    boost::int32_t tx = 0;
    boost::int32_t ty = 0;
    if (translate_nbits) {
        in.ensureBits(translate_nbits * 2);
        tx = in.read_sint(translate_nbits);
        ty = in.read_sint(translate_nbits);
    }
    return SWFMatrix(sx, shx, shy, sy, tx, ty);
}
예제 #9
0
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());

}