You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having problem using the bitmapdata encode to png, and the new BitmapData.decode, the bitmapdata currently transparent lose the transparency.
public function addTexture(texture:BitmapData):void
{
var bitmapEncoded:ByteArray = texture.encode(texture.rect, new PNGEncoderOptions());
var randomIdentifierBytes:ByteArray = Digest.hash(Digest.SHA256, bitmapEncoded);
var randomIdentifier:String = Base64.encodeByteArray(randomIdentifierBytes);
_textures.push(randomIdentifier);
var sharedObject:SharedObject = SharedObject.getLocal("redesurftank/textures/" + randomIdentifier);
sharedObject.data.texture = bitmapEncoded;
sharedObject.flush();
sharedObject.close();
}
public function getTexture(index:int):BitmapData
{
var randomIdentifier:String = _textures[index];
var sharedObject:SharedObject = SharedObject.getLocal("redesurftank/textures/" + randomIdentifier);
var textureBytes:ByteArray = sharedObject.data.texture;
textureBytes.position = 0;
var texture:BitmapData = BitmapData.decode(textureBytes);
sharedObject.close();
return texture;
}
The text was updated successfully, but these errors were encountered:
"All pixels in a BitmapData object are stored as premultiplied color values. A premultiplied image pixel has the red, green, and blue color channel values already multiplied by the alpha data. For example, if the alpha value is 0, the values for the RGB channels are also 0, independent of their unmultiplied values. This loss of data can cause some problems when you perform operations. All BitmapData methods take and return unmultiplied values. The internal pixel representation is converted from premultiplied to unmultiplied before it is returned as a value. During a set operation, the pixel value is premultiplied before the raw image pixel is set."
Actually it does look like this is a problem in the line: BitmapData.decode(textureBytes);
The byte array there contains a PNG that includes transparency, so the decoded bitmap data should also contain the same... the issue seems to be caused by the initial generation of the BitmapData object (internally) that's then returned from the static method, after the decoded PNG is drawn onto it.
Should be fixed in our next cross-platform release - within the next week or two - version 50.2.4
I'm having problem using the bitmapdata encode to png, and the new BitmapData.decode, the bitmapdata currently transparent lose the transparency.
The text was updated successfully, but these errors were encountered: