Browse Source

implemented loadBitmap

ncannasse 9 years ago
parent
commit
fae32bfbd5
1 changed files with 13 additions and 0 deletions
  1. 13 0
      hxd/fs/BytesFileSystem.hx

+ 13 - 0
hxd/fs/BytesFileSystem.hx

@@ -48,7 +48,20 @@ class BytesFileEntry extends FileEntry {
 	}
 
 	override function loadBitmap( onLoaded : LoadedBitmap -> Void ) : Void {
+		#if flash
+		var loader = new flash.display.Loader();
+		loader.contentLoaderInfo.addEventListener(flash.events.IOErrorEvent.IO_ERROR, function(e:flash.events.IOErrorEvent) {
+			throw Std.string(e) + " while loading " + fullPath;
+		});
+		loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function(_) {
+			var content : flash.display.Bitmap = cast loader.content;
+			onLoaded(new hxd.fs.LoadedBitmap(content.bitmapData));
+			loader.unload();
+		});
+		loader.loadBytes(bytes.getData());
+		#else
 		throw "TODO";
+		#end
 	}
 
 	override function exists( name : String ) : Bool return false;