cocos2d/cocos2d-x — pull request #4489 by pyrasis (2013-12-15 12:32:12+00:00)
Title: fix CCImage bug on android platform.

- android.graphics.Bitmap bytes are aleady RGBA
- delete swapAlphaChannel and swapAlpha

Hello.

I've been testing TTF font with shadow and stroke on android platform recently. so, I've found a problem with swap alpha function.

![android_shadowstroke1](https://f.cloud.github.com/assets/210015/1750286/2a2e1be2-6582-11e3-914e-d09ec75aba16.png)
there are wrong colors.

so, I filled red color in font rect.
Cocos2dxBitmap.java

final Bitmap bitmap = Bitmap.createBitmap(textProperty.mMaxWidth + (int)bitmapPaddingX,
bitmapTotalHeight + (int)bitmapPaddingY, Bitmap.Config.ARGB_8888);
bitmap.eraseColor(Color.RED); // fill red color
final Canvas canvas = new Canvas(bitmap);

and I wrote some logs.

CCImage.cpp

// swap the alpha channel (ARGB to RGBA)
CCLOG("BYTE! =============0 %08x", ((unsigned int *)_data)[0]);
swapAlphaChannel((unsigned int *)_data, (_width * _height) );
CCLOG("BYTE! =============1 %08x", ((unsigned int *)_data)[0]);

// swap data
unsigned int *tempPtr = (unsigned int*)bitmapDC._data;
unsigned int *ptr0 = &tempPtr[0];
CCLOG("BYTE! !!!!!!!!!!!!!! %08x", *ptr0);
unsigned int tempdata = 0;
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; ++j)
{
tempdata = *tempPtr;
*tempPtr++ = bitmapDC.swapAlpha(tempdata);
}
}
CCLOG("BYTE! -------------- %08x", *ptr0);

![android_shadowstroke2](https://f.cloud.github.com/assets/210015/1750295/f9dfd434-6582-11e3-83a8-18920a004243.png)

these are the logs.
12-15 20:17:42.540: D/cocos2d-x debug info(2694): BYTE! !!!!!!!!!!!!!! ff0000ff
12-15 20:17:42.570: D/cocos2d-x debug info(2694): BYTE! -------------- 0000ffff
12-15 20:17:42.570: D/cocos2d-x debug info(2694): BYTE! =============0 0000ffff
12-15 20:17:42.580: D/cocos2d-x debug info(2694): BYTE! =============1 ffffffff
12-15 20:17:42.580: D/cocos2d-x debug info(2694): BYTE! ffffffff internalFormat: 1908, format: 1908
12-15 20:17:42.700: D/cocos2d-x debug info(2694): BYTE! !!!!!!!!!!!!!! ff0000ff
12-15 20:17:42.700: D/cocos2d-x debug info(2694): BYTE! -------------- 0000ffff
12-15 20:17:42.700: D/cocos2d-x debug info(2694): BYTE! =============0 0000ffff
12-15 20:17:42.700: D/cocos2d-x debug info(2694): BYTE! =============1 ffffffff
12-15 20:17:42.700: D/cocos2d-x debug info(2694): BYTE! ffffffff internalFormat: 1908, format: 1908
12-15 20:17:42.850: D/cocos2d-x debug info(2694): BYTE! !!!!!!!!!!!!!! ff0000ff
12-15 20:17:42.850: D/cocos2d-x debug info(2694): BYTE! -------------- 0000ffff
12-15 20:17:42.850: D/cocos2d-x debug info(2694): BYTE! =============0 0000ffff
12-15 20:17:42.850: D/cocos2d-x debug info(2694): BYTE! =============1 ffffffff
12-15 20:17:42.850: D/cocos2d-x debug info(2694): BYTE! ffffffff internalFormat: 1908, format: 1908

0000ffff -> ffffffff this is wrong processing.

![initnativeobject](https://f.cloud.github.com/assets/210015/1750305/a4488ef6-6584-11e3-9bbf-392cb927824f.png)

And android.graphics.Bitmap pixel bytes are aleady RGBA.

-1, 0, 0, -1
255, 0, 0, 255
R, G, B, A
(I filled red color before)

so, I've deleted swapAlphaChannel and swapAlpha functions.

![android_shadowstroke3](https://f.cloud.github.com/assets/210015/1750308/e7d80aac-6584-11e3-9069-21da596a91b0.png)

thanks.