|
@@ -1,16 +1,16 @@
|
|
package hxd.res;
|
|
package hxd.res;
|
|
|
|
|
|
class Image extends Resource {
|
|
class Image extends Resource {
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
Specify if we will automatically convert non-power-of-two textures to power-of-two.
|
|
Specify if we will automatically convert non-power-of-two textures to power-of-two.
|
|
**/
|
|
**/
|
|
public static var ALLOW_NPOT = #if flash11_8 true #else false #end;
|
|
public static var ALLOW_NPOT = #if flash11_8 true #else false #end;
|
|
public static var DEFAULT_FILTER : h3d.mat.Data.Filter = Linear;
|
|
public static var DEFAULT_FILTER : h3d.mat.Data.Filter = Linear;
|
|
-
|
|
|
|
|
|
+
|
|
var tex : h3d.mat.Texture;
|
|
var tex : h3d.mat.Texture;
|
|
var inf : { width : Int, height : Int, isPNG : Bool };
|
|
var inf : { width : Int, height : Int, isPNG : Bool };
|
|
-
|
|
|
|
|
|
+
|
|
public function isPNG() {
|
|
public function isPNG() {
|
|
getSize();
|
|
getSize();
|
|
return inf.isPNG;
|
|
return inf.isPNG;
|
|
@@ -64,7 +64,7 @@ class Image extends Resource {
|
|
inf = { width : width, height : height, isPNG : isPNG };
|
|
inf = { width : width, height : height, isPNG : isPNG };
|
|
return inf;
|
|
return inf;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function getPixels() {
|
|
public function getPixels() {
|
|
getSize();
|
|
getSize();
|
|
if( inf.isPNG ) {
|
|
if( inf.isPNG ) {
|
|
@@ -79,7 +79,7 @@ class Image extends Resource {
|
|
return new Pixels(p.width,p.height,p.pixels, BGRA);
|
|
return new Pixels(p.width,p.height,p.pixels, BGRA);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function toBitmap() : hxd.BitmapData {
|
|
public function toBitmap() : hxd.BitmapData {
|
|
getSize();
|
|
getSize();
|
|
var bmp = new hxd.BitmapData(inf.width, inf.height);
|
|
var bmp = new hxd.BitmapData(inf.width, inf.height);
|
|
@@ -88,7 +88,7 @@ class Image extends Resource {
|
|
pixels.dispose();
|
|
pixels.dispose();
|
|
return bmp;
|
|
return bmp;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
function loadTexture() {
|
|
function loadTexture() {
|
|
if( inf.isPNG ) {
|
|
if( inf.isPNG ) {
|
|
function load() {
|
|
function load() {
|
|
@@ -121,7 +121,7 @@ class Image extends Resource {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function toTexture() : h3d.mat.Texture {
|
|
public function toTexture() : h3d.mat.Texture {
|
|
if( tex != null )
|
|
if( tex != null )
|
|
return tex;
|
|
return tex;
|
|
@@ -135,15 +135,15 @@ class Image extends Resource {
|
|
height = th;
|
|
height = th;
|
|
}
|
|
}
|
|
tex = new h3d.mat.Texture(width, height, [NoAlloc]);
|
|
tex = new h3d.mat.Texture(width, height, [NoAlloc]);
|
|
- tex.filter = DEFAULT_FILTER;
|
|
|
|
|
|
+ if( DEFAULT_FILTER != Linear ) tex.filter = DEFAULT_FILTER;
|
|
tex.setName(entry.path);
|
|
tex.setName(entry.path);
|
|
loadTexture();
|
|
loadTexture();
|
|
return tex;
|
|
return tex;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function toTile() : h2d.Tile {
|
|
public function toTile() : h2d.Tile {
|
|
var size = getSize();
|
|
var size = getSize();
|
|
return h2d.Tile.fromTexture(toTexture()).sub(0, 0, size.width, size.height);
|
|
return h2d.Tile.fromTexture(toTexture()).sub(0, 0, size.width, size.height);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|