From 2681ed21acbee3ac419c83640d49e0d1e8159d0f Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Thu, 7 Jun 2018 18:06:47 -0700 Subject: [PATCH] Fixing image encoding format conversion. (flutter/engine#5489) On a Linux host, we were having to convert the type of the bitmap to N32, but we weren't also fixing the channel order to RGBA, so consequently we were getting BGRA when the API was asking for RGBA. This forces the color format to be RGBA when that is what is asked for. We weren't needing to do conversion on macOS, so macOS was always getting RGBA. --- engine/src/flutter/lib/ui/painting/image_encoding.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting/image_encoding.cc b/engine/src/flutter/lib/ui/painting/image_encoding.cc index 6db7fcf679..c32c06cc2d 100644 --- a/engine/src/flutter/lib/ui/painting/image_encoding.cc +++ b/engine/src/flutter/lib/ui/painting/image_encoding.cc @@ -86,9 +86,10 @@ sk_sp EncodeImage(sk_sp image, ImageByteFormat format) { if (pixmap.colorType() != kRGBA_8888_SkColorType) { TRACE_EVENT0("flutter", "ConvertToRGBA"); - // Convert the pixel data to N32 to adhere to our API contract. - const auto image_info = SkImageInfo::MakeN32Premul(image->width(), - image->height()); + // Convert the pixel data to N32 and RGBA to adhere to our API contract. + const auto image_info = SkImageInfo::MakeN32Premul( + image->width(), image->height()).makeColorType(kRGBA_8888_SkColorType); + auto surface = SkSurface::MakeRaster(image_info); surface->writePixels(pixmap, 0, 0); if (!surface->peekPixels(&pixmap)) {