Nicolas Cannasse пре 12 година
родитељ
комит
087c5e496d
2 измењених фајлова са 16 додато и 0 уклоњено
  1. 4 0
      hxd/res/Any.hx
  2. 12 0
      hxd/res/Texture.hx

+ 4 - 0
hxd/res/Any.hx

@@ -42,6 +42,10 @@ class Any extends Resource {
 		return loader.loadFont(entry.path);
 	}
 
+	public function toBitmap() {
+		return loader.loadTexture(entry.path).toBitmap();
+	}
+
 	public function toBitmapFont() {
 		return loader.loadBitmapFont(entry.path);
 	}

+ 12 - 0
hxd/res/Texture.hx

@@ -83,6 +83,18 @@ class Texture extends Resource {
 		}
 	}
 	
+	public function toBitmap() : hxd.BitmapData {
+		var bmp = null;
+		#if flash
+		var size = getSize();
+		bmp = new flash.display.BitmapData(size.width, size.height, true, 0);
+		var bytes = getPixels();
+		bmp.setPixels(bmp.rect, bytes.getData());
+		hxd.impl.Tmp.saveBytes(bytes);
+		#end
+		return hxd.BitmapData.fromNative(bmp);
+	}
+	
 	function makeSquare( bmp : haxe.io.Bytes ) {
 		var tw = tex.width, th = tex.height, w = inf.width, h = inf.height;
 		var out = hxd.impl.Tmp.getBytes(tw * th * 4);