Hello,
I have ported Andorid 4.0.1 to KZM-A9-Dual board.
(http://www.kmckk.co.jp/eng/kzma9/index.html)
The framebuffer of this board is BGRA_8888 format.
I found screen chapter is not working. It print in wrong color, blue
and red are reversed.
It is becasue the screencap does not aware BGRA_8888 format frame
buffer.
It only support RGBA_8888 in 32 bit per pixels.
I made quick fix of it.
frameworks/base
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/
screencap.cpp
index 7a599e9..46c7386 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -73,8 +73,11 @@ static status_t vinfoToPixelFormat(const
fb_var_screeninfo& vinfo,
*bytespp = 3;
break;
case 32:
- // TODO: do better decoding of vinfo here
- *f = PIXEL_FORMAT_RGBX_8888;
+ if (vinfo.red.offset == 16) { // ARGB8888
+ *f = PIXEL_FORMAT_BGRA_8888;
+ } else {
+ *f = PIXEL_FORMAT_RGBX_8888;
+ }
*bytespp = 4;
break;
default:
@@ -83,6 +86,30 @@ static status_t vinfoToPixelFormat(const
fb_var_screeninfo& vinfo,
return NO_ERROR;
}
+char const*
+exchange_rb(char const* base, size_t size)
+{
+ char* mapbase;
+ char r, g, b, a;
+ int i;
+
+ mapbase = (char*)mmap(0, size, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (mapbase != MAP_FAILED) {
+ while (i < size) {
+ b = base[i];
+ g = base[i + 1];
+ r = base[i + 2];
+ a = base[i + 3];
+ mapbase[i] = r;
+ mapbase[i + 1] = g;
+ mapbase[i + 2] = b;
+ mapbase[i + 3] = a;
+ i += 4;
+ }
+ }
+ return mapbase;
+}
+
int main(int argc, char** argv)
{
const char* pname = argv[0];
@@ -163,6 +190,10 @@ int main(int argc, char** argv)
if (base) {
if (png) {
SkBitmap b;
+ if (f == PIXEL_FORMAT_BGRA_8888) {
+ base = (void const*)exchange_rb((char const*)base,
size);
+ f = PIXEL_FORMAT_RGBX_8888;
+ }
b.setConfig(flinger2skia(f), w, h);
b.setPixels((void*)base);
SkDynamicMemoryWStream stream;
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting