Haxe 3.2.0 can't get BytesData length or access it like an array

51 views
Skip to first unread message

Zanollo

unread,
Oct 16, 2015, 12:57:29 PM10/16/15
to Haxe
I could do it before but after the update it throws:

"haxe.io.BytesData has no field length"
"Array access is not allowed on haxe.io.BytesData"

What I have to do is read the bytes of two textures, make something with them and write the result onto another texture.

Before I could do it like this:
 
private function cropImageSprite(sourceId:String, destination:ImageSprite, mask:ImageSprite, fromX:Int, fromY:Int) {
var maskPixels = mask.texture.readPixels(0, 0, mask.texture.width, mask.texture.height).getData();
var sourceImage = new ImageSprite(assetManager.getTexture(sourceId));
var sourcePixels:Bytes = sourceImage.texture.readPixels(fromX, fromY, mask.texture.width, mask.texture.height);
var sourcePixelsData = sourcePixels.getData();
for (i in 0...sourcePixelsData.length) {
sourcePixelsData[i] = sourcePixelsData[i] & maskPixels[i];
}
destination.texture.writePixels(sourcePixels, 0, 0, mask.texture.width, mask.texture.height);
}

Reply all
Reply to author
Forward
0 new messages