Skip to content

Commit

Permalink
added TBackgroundColor
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Apr 18, 2009
1 parent 92558ca commit 3e713d3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,7 @@
2009-04-18: 1.09
swf : added TBackgroundColor tag
swf : fixed InflateImpl for JS/Flash8

2009-01-12: 1.08
swf : fixed UTF8 issues in labels and instance names
swf : added lossless bits (require "ext" tag mode)
Expand Down
1 change: 1 addition & 0 deletions format/swf/Data.hx
Expand Up @@ -40,6 +40,7 @@ typedef SWF = {
enum SWFTag {
TShowFrame;
TShape( id : Int, version : Int, data : haxe.io.Bytes );
TBackgroundColor( color : Int );
TClip( id : Int, frames : Int, tags : Array<SWFTag> );
TPlaceObject2( po : PlaceObject );
TPlaceObject3( po : PlaceObject );
Expand Down
2 changes: 2 additions & 0 deletions format/swf/Reader.hx
Expand Up @@ -348,6 +348,8 @@ class Reader {
TShowFrame;
case 0x02:
readShape(len,1);
case 0x09:
TBackgroundColor(i.readUInt24());
case 0x14:
TBitsLossless(readLossless(len,false));
case 0x16:
Expand Down
35 changes: 35 additions & 0 deletions format/swf/Tools.hx
Expand Up @@ -28,6 +28,7 @@
* DAMAGE.
*/
package format.swf;
import format.swf.Data;

class Tools {

Expand Down Expand Up @@ -60,4 +61,38 @@ class Tools {
return (i << 8) | Std.int((f-i)*256.0);
}

public static function hex( b : haxe.io.Bytes, ?max : Int ) {
var hex = ["0".code,"1".code,"2".code,"3".code,"4".code,"5".code,"6".code,"7".code,"8".code,"9".code,"A".code,"B".code,"C".code,"D".code,"E".code,"F".code];
var count = if( max == null || b.length <= max ) b.length else max;
var buf = new StringBuf();
for( i in 0...count ) {
var v = b.get(i);
buf.addChar(hex[v>>4]);
buf.addChar(hex[v&15]);
}
if( count < b.length )
buf.add("...");
return buf.toString();
}

public static function dumpTag( t : SWFTag, ?max : Int ) {
var infos = switch( t ) {
case TShowFrame: [];
case TBackgroundColor(color): [StringTools.hex(color,6)];
case TShape(id,version,data): ["id",id,"version",version,"data",hex(data,max)];
case TClip(id,frames,tags): ["id",id,"frames",frames];
case TPlaceObject2(po): [Std.string(po)];
case TPlaceObject3(po): [Std.string(po)];
case TRemoveObject2(d): ["depth",d];
case TFrameLabel(label,anchor): ["label",label,"anchor",anchor];
case TDoInitActions(id,data): ["id",id,"data",hex(data,max)];
case TActionScript3(data,context): ["context",context,"data",hex(data,max)];
case TSymbolClass(symbols): [Std.string(symbols)];
case TSandBox(v): [v];
case TBitsLossless(l),TBitsLossless2(l): ["id",l.cid,"bits",l.bits,"width",l.width,"height",l.height,"data",hex(l.data,max)];
case TUnknown(id,data): ["id",id,"data",hex(data,max)];
}
return Type.enumConstructor(t)+"("+infos.join(",")+")";
}

}
2 changes: 2 additions & 0 deletions format/swf/Writer.hx
Expand Up @@ -295,6 +295,8 @@ class Writer {
writeTID([0,0x02,0x16,0x20,0x53,0x54][ver],data.length + 2);
o.writeUInt16(id);
o.write(data);
case TBackgroundColor(color):
o.writeUInt24(color);
case TPlaceObject2(po):
var t = openTMP();
writePlaceObject(po,false);
Expand Down

0 comments on commit 3e713d3

Please sign in to comment.