From 4b86cec4be2350a7a61ed596fb53b8586c6d6b89 Mon Sep 17 00:00:00 2001 From: yangws Date: Mon, 28 Mar 2011 10:44:14 +0800 Subject: [PATCH 1/5] issue #396 win32 modifyed. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 6 +- cocos2dx/platform/CCCommon.h | 70 ----------- cocos2dx/platform/CCImage.cpp | 134 ++++++++++++---------- cocos2dx/platform/CCImage.h | 9 +- cocos2dx/platform/win32/CCImage_win32.cpp | 16 +-- cocos2dx/textures/CCTexture2D.cpp | 20 ++-- 6 files changed, 103 insertions(+), 152 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index e20ae7a1e3..4d76e98f98 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -433,7 +433,7 @@ namespace cocos2d{ { int nextFontPositionX = 0; int nextFontPositionY = 0; - ccxInt16 prev = -1; + unsigned short prev = -1; int kerningAmount = 0; CCSize tmpSize = CCSizeZero; @@ -452,7 +452,7 @@ namespace cocos2d{ for (int i = 0; i < len - 1; ++i) { - ccxInt16 c = m_sString[i]; + unsigned short c = m_sString[i]; if (c == '\n') { quantityOfLines++; @@ -464,7 +464,7 @@ namespace cocos2d{ for(int i=0; i void operator()(TPTR ) {} }; -struct ccxNewDeleter { template< class TPTR > void operator()(TPTR p) { delete p; } }; -struct ccxNewArrayDeleter { template< class TPTR > void operator()(TPTR p) { delete[] p; } }; - -/** -@brief A simple scoped pointer. -*/ -template < class T, class D = ccxNewDeleter > -class CC_DLL ccxScopedPtr // noncopyable - : private D -{ -public: - explicit ccxScopedPtr(T * p = 0): m_ptr(p) {} - ~ccxScopedPtr() { if (m_ptr) (*static_cast(this))(m_ptr); } - - void reset(T * p = 0) { ccxScopedPtr< T >(p).swap(*this); } - T * get() const { return m_ptr; } - void swap(ccxScopedPtr & b) { T * tmp = b.m_ptr; b.m_ptr = m_ptr; m_ptr = tmp; } - - T & operator*() const { return * m_ptr; } - T * operator->() const { return m_ptr; } - operator bool () const { return m_ptr != 0; } - -private: - ccxScopedPtr(const ccxScopedPtr&); - ccxScopedPtr & operator=(const ccxScopedPtr&); - - void operator==(const ccxScopedPtr& ) const; - void operator!=(const ccxScopedPtr& ) const; - - T * m_ptr; -}; -/** -@brief A simple scoped point for array. -*/ -template< class T, class D = ccxNewArrayDeleter > -class CC_DLL ccxScopedArray // noncopyable - : private D -{ -public: - explicit ccxScopedArray( T * p = 0 ) : m_ptr( p ) {} - ~ccxScopedArray() { if (m_ptr) (*static_cast(this))(m_ptr); } - - void reset(T * p = 0) { ccxScopedArray(p).swap(*this); } - T * get() const { return m_ptr; } - void swap(ccxScopedArray & b) { T * tmp = b.m_ptr; b.m_ptr = m_ptr; m_ptr = tmp; } - - T & operator[](int i) const { CC_ASSERT(m_ptr && i >= 0); return m_ptr[i]; } - operator bool () const { return m_ptr != 0; } - -private: - ccxScopedArray(ccxScopedArray const &); - ccxScopedArray & operator=(ccxScopedArray const &); - - void operator==( ccxScopedArray const& ) const; - void operator!=( ccxScopedArray const& ) const; - - T * m_ptr; -}; - NS_CC_END; #endif // __CC_COMMON_H__ diff --git a/cocos2dx/platform/CCImage.cpp b/cocos2dx/platform/CCImage.cpp index 26300864b7..4c15f1b5c2 100644 --- a/cocos2dx/platform/CCImage.cpp +++ b/cocos2dx/platform/CCImage.cpp @@ -34,10 +34,10 @@ THE SOFTWARE. #undef QGLOBAL_H #define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \ - (unsigned)(((unsigned)((ccxByte)(vr) * ((ccxByte)(va) + 1)) >> 8) | \ - ((unsigned)((ccxByte)(vg) * ((ccxByte)(va) + 1) >> 8) << 8) | \ - ((unsigned)((ccxByte)(vb) * ((ccxByte)(va) + 1) >> 8) << 16) | \ - ((unsigned)(ccxByte)(va) << 24)) + (unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \ + ((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \ + ((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \ + ((unsigned)(unsigned char)(va) << 24)) typedef struct { @@ -73,12 +73,18 @@ CCImage::CCImage() : m_nWidth(0) , m_nHeight(0) , m_nBitsPerComponent(0) +, m_pData(0) , m_bHasAlpha(false) , m_bPreMulti(false) { } +CCImage::~CCImage() +{ + CC_SAFE_DELETE_ARRAY(m_pData); +} + bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { bool bRet = false; @@ -167,73 +173,79 @@ bool CCImage::_initWithJpgData(void * data, int nSize) struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; /* libjpeg data structure for storing one row, that is, scanline of an image */ - JSAMPROW row_pointer[1]; - + JSAMPROW row_pointer[1] = {0}; unsigned long location = 0; unsigned int i = 0; - /* here we set up the standard libjpeg error handler */ - cinfo.err = jpeg_std_error( &jerr ); - - /* setup decompression process and source, then read JPEG header */ - jpeg_create_decompress( &cinfo ); - - /* this makes the library read from infile */ - jpeg_mem_src( &cinfo, (unsigned char *) data, nSize ); - - /* reading the image header which contains image information */ - jpeg_read_header( &cinfo, true ); - - // we only support RGB or grayscale - if (cinfo.jpeg_color_space != JCS_RGB) + bool bRet = false; + do { - if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr) + /* here we set up the standard libjpeg error handler */ + cinfo.err = jpeg_std_error( &jerr ); + + /* setup decompression process and source, then read JPEG header */ + jpeg_create_decompress( &cinfo ); + + /* this makes the library read from infile */ + jpeg_mem_src( &cinfo, (unsigned char *) data, nSize ); + + /* reading the image header which contains image information */ + jpeg_read_header( &cinfo, true ); + + // we only support RGB or grayscale + if (cinfo.jpeg_color_space != JCS_RGB) { - cinfo.out_color_space = JCS_RGB; + if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr) + { + cinfo.out_color_space = JCS_RGB; + } + } + else + { + break; } - } - else - { - return false; - } - /* Start decompression jpeg here */ - jpeg_start_decompress( &cinfo ); + /* Start decompression jpeg here */ + jpeg_start_decompress( &cinfo ); - /* init image info */ - m_nWidth = cinfo.image_width; - m_nHeight = cinfo.image_height; - m_bHasAlpha = false; - m_bPreMulti = false; - m_nBitsPerComponent = 8; - m_pData.reset(new ccxByte[cinfo.output_width*cinfo.output_height*cinfo.output_components]); - ccxByte * pData = m_pData.get(); + /* init image info */ + m_nWidth = cinfo.image_width; + m_nHeight = cinfo.image_height; + m_bHasAlpha = false; + m_bPreMulti = false; + m_nBitsPerComponent = 8; + row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components]; + CC_BREAK_IF(! row_pointer[0]); - /* now actually read the jpeg into the raw buffer */ - row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components]; + m_pData = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components]; + CC_BREAK_IF(! m_pData); - /* read one scan line at a time */ - while( cinfo.output_scanline < cinfo.image_height ) - { - jpeg_read_scanlines( &cinfo, row_pointer, 1 ); - for( i=0; i m_pData; + unsigned char * m_pData; bool m_bHasAlpha; bool m_bPreMulti; diff --git a/cocos2dx/platform/win32/CCImage_win32.cpp b/cocos2dx/platform/win32/CCImage_win32.cpp index 42ca84ec96..46a76a3181 100644 --- a/cocos2dx/platform/win32/CCImage_win32.cpp +++ b/cocos2dx/platform/win32/CCImage_win32.cpp @@ -273,6 +273,7 @@ bool CCImage::initWithString( int nSize/* = 0*/) { bool bRet = false; + unsigned char * pImageData = 0; do { CC_BREAK_IF(! pText); @@ -289,8 +290,8 @@ bool CCImage::initWithString( SIZE size = {nWidth, nHeight}; CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask)); - m_pData.reset(new ccxByte[size.cx * size.cy * 4]); - CC_BREAK_IF(! m_pData.get()); + pImageData = new unsigned char[size.cx * size.cy * 4]; + CC_BREAK_IF(! pImageData); struct { @@ -301,23 +302,24 @@ bool CCImage::initWithString( CC_BREAK_IF(! GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0, NULL, (LPBITMAPINFO)&bi, DIB_RGB_COLORS)); - m_nWidth = (ccxInt16)size.cx; - m_nHeight = (ccxInt16)size.cy; + m_nWidth = (short)size.cx; + m_nHeight = (short)size.cy; m_bHasAlpha = true; m_bPreMulti = false; + m_pData = pImageData; + pImageData = 0; m_nBitsPerComponent = 8; - // copy pixed data bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0) ? - bi.bmiHeader.biHeight : bi.bmiHeader.biHeight; - GetDIBits(dc.getDC(), dc.getBitmap(), 0, m_nHeight, m_pData.get(), + GetDIBits(dc.getDC(), dc.getBitmap(), 0, m_nHeight, m_pData, (LPBITMAPINFO)&bi, DIB_RGB_COLORS); // change pixel's alpha value to 255, when it's RGB != 0 COLORREF * pPixel = NULL; for (int y = 0; y < m_nHeight; ++y) { - pPixel = (COLORREF *)m_pData.get() + y * m_nWidth; + pPixel = (COLORREF *)m_pData + y * m_nWidth; for (int x = 0; x < m_nWidth; ++x) { COLORREF& clr = *pPixel; diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 5900dc2803..089cf7520d 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -432,21 +432,21 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in // info = kCGImageAlphaOnly; // context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info); - tempData = (ccxByte*)(image->getData()); + tempData = (unsigned char*)(image->getData()); CCAssert(tempData != NULL, "NULL image data."); if(image->getWidth() == POTWide && image->getHeight() == POTHigh) { - data = new ccxByte[POTHigh * POTWide * 4]; + data = new unsigned char[POTHigh * POTWide * 4]; memcpy(data, tempData, POTHigh * POTWide * 4); } else { - data = new ccxByte[POTHigh * POTWide * 4]; + data = new unsigned char[POTHigh * POTWide * 4]; memset(data, 0, POTHigh * POTWide * 4); - ccxByte* pPixelData = (ccxByte*) tempData; - ccxByte* pTargetData = (ccxByte*) data; + unsigned char* pPixelData = (unsigned char*) tempData; + unsigned char* pTargetData = (unsigned char*) data; for(int y=0; ygetHeight(); ++y) { @@ -456,20 +456,20 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in break; case kCCTexture2DPixelFormat_RGB888: - tempData = (ccxByte*)(image->getData()); + tempData = (unsigned char*)(image->getData()); CCAssert(tempData != NULL, "NULL image data."); if(image->getWidth() == POTWide && image->getHeight() == POTHigh) { - data = new ccxByte[POTHigh * POTWide * 3]; + data = new unsigned char[POTHigh * POTWide * 3]; memcpy(data, tempData, POTHigh * POTWide * 3); } else { - data = new ccxByte[POTHigh * POTWide * 3]; + data = new unsigned char[POTHigh * POTWide * 3]; memset(data, 0, POTHigh * POTWide * 3); - ccxByte* pPixelData = (ccxByte*) tempData; - ccxByte* pTargetData = (ccxByte*) data; + unsigned char* pPixelData = (unsigned char*) tempData; + unsigned char* pTargetData = (unsigned char*) data; for(int y=0; ygetHeight(); ++y) { From dceff2d179d9e90ed2a08f9fcb583613d5b8ce50 Mon Sep 17 00:00:00 2001 From: yangws Date: Mon, 28 Mar 2011 11:09:49 +0800 Subject: [PATCH 2/5] issue #396 android modified. --- cocos2dx/platform/CCThread.h | 2 +- cocos2dx/platform/android/CCImage_android.cpp | 10 +++++----- cocos2dx/platform/android/CCThread_android.cpp | 5 +---- cocos2dx/platform/win32/CCThread_win32.cpp | 1 + cocos2dx/platform/wophone/CCThread_wophone.cpp | 1 + cocos2dx/textures/CCTexture2D.cpp | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cocos2dx/platform/CCThread.h b/cocos2dx/platform/CCThread.h index aeebfc5426..681d3fc614 100644 --- a/cocos2dx/platform/CCThread.h +++ b/cocos2dx/platform/CCThread.h @@ -46,7 +46,7 @@ public: private: class Impl; - ccxScopedPtr m_pImp; + CCLock::Impl * m_pImp; }; #else // CC_SUPPORT_MULTITHREAD diff --git a/cocos2dx/platform/android/CCImage_android.cpp b/cocos2dx/platform/android/CCImage_android.cpp index c165b371a1..95f8f24d3c 100644 --- a/cocos2dx/platform/android/CCImage_android.cpp +++ b/cocos2dx/platform/android/CCImage_android.cpp @@ -233,12 +233,12 @@ bool CCImage::initWithString( CC_BREAK_IF(nWidth <= 0 || nHeight <= 0); int nDataLen = pBitmap->rowBytes() * pBitmap->height(); - m_pData.reset(new ccxByte[nDataLen]); - CC_BREAK_IF(! m_pData.get()); - memcpy((void*) m_pData.get(), pBitmap->getPixels(), nDataLen); + m_pData = new unsigned char[nDataLen]; + CC_BREAK_IF(! m_pData); + memcpy((void*) m_pData, pBitmap->getPixels(), nDataLen); - m_nWidth = (ccxInt16)nWidth; - m_nHeight = (ccxInt16)nHeight; + m_nWidth = (short)nWidth; + m_nHeight = (short)nHeight; m_bHasAlpha = true; m_bPreMulti = true; m_nBitsPerComponent = pBitmap->bytesPerPixel(); diff --git a/cocos2dx/platform/android/CCThread_android.cpp b/cocos2dx/platform/android/CCThread_android.cpp index 537eb7690d..cff54e0af2 100644 --- a/cocos2dx/platform/android/CCThread_android.cpp +++ b/cocos2dx/platform/android/CCThread_android.cpp @@ -52,10 +52,7 @@ CCLock::CCLock() CCLock::~CCLock() { - if (m_pImp) - { - delete m_pImp; - } + CC_SAFE_DELETE(m_pImp); } void CCLock::lock() diff --git a/cocos2dx/platform/win32/CCThread_win32.cpp b/cocos2dx/platform/win32/CCThread_win32.cpp index 50419432d3..27a1c4df65 100644 --- a/cocos2dx/platform/win32/CCThread_win32.cpp +++ b/cocos2dx/platform/win32/CCThread_win32.cpp @@ -46,6 +46,7 @@ CCXLock::CCXLock() CCXLock::~CCXLock() { + CC_SAFE_DELETE(m_pImp); } void CCXLock::lock() diff --git a/cocos2dx/platform/wophone/CCThread_wophone.cpp b/cocos2dx/platform/wophone/CCThread_wophone.cpp index 3633eb75a4..5c1ea0f4cc 100644 --- a/cocos2dx/platform/wophone/CCThread_wophone.cpp +++ b/cocos2dx/platform/wophone/CCThread_wophone.cpp @@ -58,6 +58,7 @@ CCLock::CCLock() CCLock::~CCLock() { + CC_SAFE_DELETE(m_pImp); } void CCLock::lock() diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 089cf7520d..3b7bf6b8e9 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -128,11 +128,11 @@ namespace cocos2d { case kCCTexture2DPixelFormat_RGB5A1: case kCCTexture2DPixelFormat_RGB565: case kCCTexture2DPixelFormat_A8: - vt->data = new ccxByte[w * h * 4]; + vt->data = new unsigned char[w * h * 4]; memcpy(vt->data, d, w * h * 4); break; case kCCTexture2DPixelFormat_RGB888: - vt->data = new ccxByte[w * h * 3]; + vt->data = new unsigned char[w * h * 3]; memcpy(vt->data, d, w * h * 3); break; } From a5040e0ccb5545954b66768c7f461c1c6bba21d7 Mon Sep 17 00:00:00 2001 From: yangws Date: Mon, 28 Mar 2011 13:41:14 +0800 Subject: [PATCH 3/5] issue 396 ios modified. --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/platform/ios/CCImage_ios.mm | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index b78b834352..786b575222 100644 --- a/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d5a987afa7d4b73559fafa94ca068affc445ddab \ No newline at end of file +f22d2c6313c35aa8df07f3d3baa449f473e6c02a \ No newline at end of file diff --git a/cocos2dx/platform/ios/CCImage_ios.mm b/cocos2dx/platform/ios/CCImage_ios.mm index 5abc8330fb..ed7e04cbf3 100644 --- a/cocos2dx/platform/ios/CCImage_ios.mm +++ b/cocos2dx/platform/ios/CCImage_ios.mm @@ -459,12 +459,18 @@ CCImage::CCImage() : m_nWidth(0) , m_nHeight(0) , m_nBitsPerComponent(0) +, m_pData(0) , m_bHasAlpha(false) , m_bPreMulti(false) { } +CCImage::~CCImage() +{ + CC_SAFE_DELETE_ARRAY(m_pData); +} + bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { bool bRet = false; @@ -483,12 +489,12 @@ bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = e } if (bRet) { - m_nHeight = (ccxInt16)info.height; - m_nWidth = (ccxInt16)info.width; + m_nHeight = (short)info.height; + m_nWidth = (short)info.width; m_nBitsPerComponent = info.bitsPerComponent; m_bHasAlpha = info.hasAlpha; m_bPreMulti = info.isPremultipliedAlpha; - m_pData.reset(info.data); + m_pData = info.data; } return bRet; } @@ -504,12 +510,12 @@ bool CCImage::initWithImageData(void * pData, int nDataLen, EImageFormat eFmt/* } while (0); if (bRet) { - m_nHeight = (ccxInt16)info.height; - m_nWidth = (ccxInt16)info.width; + m_nHeight = (short)info.height; + m_nWidth = (short)info.width; m_nBitsPerComponent = info.bitsPerComponent; m_bHasAlpha = info.hasAlpha; m_bPreMulti = info.isPremultipliedAlpha; - m_pData.reset(info.data); + m_pData = info.data; } return bRet; } @@ -530,12 +536,12 @@ bool CCImage::initWithString( { return false; } - m_nHeight = (ccxInt16)info.height; - m_nWidth = (ccxInt16)info.width; + m_nHeight = (short)info.height; + m_nWidth = (short)info.width; m_nBitsPerComponent = info.bitsPerComponent; m_bHasAlpha = info.hasAlpha; m_bPreMulti = info.isPremultipliedAlpha; - m_pData.reset(info.data); + m_pData = info.data; return true; } From a9f85a2daa99c857e757c643c8557f546cb0573a Mon Sep 17 00:00:00 2001 From: yangws Date: Mon, 28 Mar 2011 17:10:05 +0800 Subject: [PATCH 4/5] issue #396 airplay modified. --- cocos2dx/platform/airplay/CCImage_airplay.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos2dx/platform/airplay/CCImage_airplay.cpp b/cocos2dx/platform/airplay/CCImage_airplay.cpp index 9288aeec91..145bb8f005 100644 --- a/cocos2dx/platform/airplay/CCImage_airplay.cpp +++ b/cocos2dx/platform/airplay/CCImage_airplay.cpp @@ -47,11 +47,17 @@ CCImage::CCImage() : m_nWidth(0) , m_nHeight(0) , m_nBitsPerComponent(0) +, m_pData(0) , m_bHasAlpha(false) , m_bPreMulti(false) { } + +CCImage::~CCImage() +{ + CC_SAFE_DELETE_ARRAY(m_pData); +} bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { IW_CALLSTACK("UIImage::initWithImageFile"); @@ -175,7 +181,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) imageSource.size = nDatalen; imageSource.offset = 0; - m_pData.reset(new ccxByte[m_nHeight * m_nWidth * bytesPerComponent]); + m_pData = new unsigned char[m_nHeight * m_nWidth * bytesPerComponent]; unsigned int bytesPerRow = m_nWidth * bytesPerComponent; @@ -184,7 +190,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) unsigned char *src = NULL; src = (unsigned char *)image->GetTexels(); - unsigned char *tmp = (unsigned char *) m_pData.get(); + unsigned char *tmp = (unsigned char *) m_pData; for(unsigned int i = 0; i < m_nHeight*bytesPerRow; i += bytesPerComponent) { @@ -199,7 +205,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) { for (int j = 0; j < (m_nHeight); ++j) { - memcpy(m_pData.get() + j * bytesPerRow, image->GetTexels()+j * bytesPerRow, bytesPerRow); + memcpy(m_pData + j * bytesPerRow, image->GetTexels()+j * bytesPerRow, bytesPerRow); } } From 6b66affbab17db06cbc267e476ee83ab818b3b6e Mon Sep 17 00:00:00 2001 From: yangws Date: Mon, 28 Mar 2011 17:20:39 +0800 Subject: [PATCH 5/5] fixed #396 wophone modified. --- cocos2dx/platform/wophone/CCImage_wophone.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2dx/platform/wophone/CCImage_wophone.cpp b/cocos2dx/platform/wophone/CCImage_wophone.cpp index 88d86746d2..5f886b5fa2 100644 --- a/cocos2dx/platform/wophone/CCImage_wophone.cpp +++ b/cocos2dx/platform/wophone/CCImage_wophone.cpp @@ -305,12 +305,12 @@ bool CCImage::initWithString( CC_BREAK_IF(nWidth <= 0 || nHeight <= 0); INT32 nDataLen = pBitmap->GetRowBytes() * nHeight; - m_pData.reset(new ccxByte[nDataLen]); - CC_BREAK_IF(! m_pData.get()); - memcpy((void*) m_pData.get(), pBitmap->GetDataPtr(), nDataLen); + m_pData = new unsigned char[nDataLen]; + CC_BREAK_IF(! m_pData); + memcpy((void*) m_pData, pBitmap->GetDataPtr(), nDataLen); - m_nWidth = (ccxInt16)nWidth; - m_nHeight = (ccxInt16)nHeight; + m_nWidth = (short)nWidth; + m_nHeight = (short)nHeight; m_bHasAlpha = true; m_bPreMulti = true; m_nBitsPerComponent = pBitmap->GetDepth() / 4;