Fix RGBA pixel layout when reading image from clipboard.

Pixel layout on Android is RGBA.

Original patch was created by zhenghao@ in Android downstream.

The changed code is used in webkit unit tests, layout tests and test_shell.

BUG=none


Review URL: https://chromiumcodereview.appspot.com/10824366

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152424 0039d316-1c4b-4281-b951-d872f2087c98
parent fbaa2875
......@@ -105,12 +105,20 @@ WebKit::WebData MockWebClipboardImpl::readImage(
// for endianess reasons, it will be BGRA8888 on Windows.
const SkBitmap& bitmap = m_image.getSkBitmap();
SkAutoLockPixels lock(bitmap);
#if defined(OS_ANDROID)
webkit_support::EncodeRGBAPNG(static_cast<unsigned char*>(bitmap.getPixels()),
bitmap.width(),
bitmap.height(),
bitmap.rowBytes(),
&encoded_image);
#else
webkit_support::EncodeBGRAPNG(static_cast<unsigned char*>(bitmap.getPixels()),
bitmap.width(),
bitmap.height(),
bitmap.rowBytes(),
false,
&encoded_image);
#endif
data.assign(reinterpret_cast<char*>(vector_as_array(&encoded_image)),
encoded_image.size());
return data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment