From 2807e785c06f254fd5a3399dc2074769d65fd28f Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sun, 15 Dec 2013 21:07:55 +0900 Subject: [PATCH] fix CCImage bug on android platform. - android.graphics.Bitmap bytes are aleady RGBA - delete swapAlphaChannel and swapAlpha --- cocos/2d/platform/android/CCImage.cpp | 37 --------------------------- 1 file changed, 37 deletions(-) diff --git a/cocos/2d/platform/android/CCImage.cpp b/cocos/2d/platform/android/CCImage.cpp index ba722d7fad..3a9dcc2f06 100644 --- a/cocos/2d/platform/android/CCImage.cpp +++ b/cocos/2d/platform/android/CCImage.cpp @@ -35,9 +35,6 @@ THE SOFTWARE. #include #include -// prototype -void swapAlphaChannel(unsigned int *pImageMemory, unsigned int numPixels); - NS_CC_BEGIN class BitmapDC @@ -129,12 +126,6 @@ public: return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize ); } - // ARGB -> RGBA - inline unsigned int swapAlpha(unsigned int value) - { - return ((value << 8 & 0xffffff00) | (value >> 24 & 0x000000ff)); - } - public: int _width; int _height; @@ -228,9 +219,6 @@ bool Image::initWithStringShadowStroke( _renderFormat = Texture2D::PixelFormat::RGBA8888; _dataLen = _width * _height * 4; - // swap the alpha channel (ARGB to RGBA) - swapAlphaChannel((unsigned int *)_data, (_width * _height) ); - // ok bRet = true; @@ -241,19 +229,6 @@ bool Image::initWithStringShadowStroke( NS_CC_END -// swap the alpha channel in an 32 bit image (from ARGB to RGBA) -void swapAlphaChannel(unsigned int *pImageMemory, unsigned int numPixels) -{ - for(int c = 0; c < numPixels; ++c, ++pImageMemory) - { - // copy the current pixel - unsigned int currenPixel = (*pImageMemory); - // swap channels and store back - char *pSource = (char *) ¤Pixel; - *pImageMemory = (pSource[0] << 24) | (pSource[3]<<16) | (pSource[2]<<8) | pSource[1]; - } -} - // this method is called by Cocos2dxBitmap extern "C" { @@ -268,17 +243,5 @@ extern "C" bitmapDC._height = height; bitmapDC._data = new unsigned char[size]; env->GetByteArrayRegion(pixels, 0, size, (jbyte*)bitmapDC._data); - - // swap data - unsigned int *tempPtr = (unsigned int*)bitmapDC._data; - unsigned int tempdata = 0; - for (int i = 0; i < height; ++i) - { - for (int j = 0; j < width; ++j) - { - tempdata = *tempPtr; - *tempPtr++ = bitmapDC.swapAlpha(tempdata); - } - } } };