Skip to content

Commit a6e61bf

Browse files
committed
Dont convert to BGRA when loading an Image, instead use its actual format
1 parent cf79b44 commit a6e61bf

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/openfl/display/BitmapData.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class BitmapData implements IBitmapDrawable
278278

279279
#if sys
280280
var buffer = new ImageBuffer(new UInt8Array(width * height * 4), width, height);
281+
281282
buffer.format = BGRA32;
282283
buffer.premultiplied = true;
283284

@@ -3228,7 +3229,6 @@ class BitmapData implements IBitmapDrawable
32283229
__textureHeight = height;
32293230

32303231
#if sys
3231-
image.format = BGRA32;
32323232
image.premultiplied = true;
32333233
#end
32343234

src/openfl/display3D/textures/TextureBase.hx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ class TextureBase extends EventDispatcher
337337
}
338338
else
339339
{
340-
internalFormat = TextureBase.__textureInternalFormat;
341-
format = TextureBase.__textureFormat;
340+
internalFormat = __limeBufferFormatToGLInternalFormat(image.buffer.format);
341+
format = __limeBufferFormatToGLFormat(image.buffer.format);
342342
}
343343

344344
__context.__bindGLTexture2D(__textureID);
@@ -389,4 +389,14 @@ class TextureBase extends EventDispatcher
389389
__memoryInternalFormat = internalFormat;
390390
}
391391
}
392+
393+
@:noCompletion private function __limeBufferFormatToGLFormat(pixelFormat:lime.graphics.PixelFormat):Int
394+
{
395+
return pixelFormat == RGBA32 ? __context.gl.RGBA : TextureBase.__textureFormat;
396+
}
397+
398+
@:noCompletion private function __limeBufferFormatToGLInternalFormat(pixelFormat:lime.graphics.PixelFormat):Int
399+
{
400+
return pixelFormat == RGBA32 ? __context.gl.RGBA : TextureBase.__textureInternalFormat;
401+
}
392402
}

0 commit comments

Comments
 (0)