mirror of https://github.com/axmolengine/axmol.git
Merge branch '396' of https://github.com/yangws/cocos2d-x into yangws-396
This commit is contained in:
commit
6cc09aa4dc
|
@ -1 +1 @@
|
|||
fc7476a3d277d2b8d1bed31ac9da0b2cb9445305
|
||||
fe4815b00d6e0564ee73979cc062a3b81ee0ae79
|
|
@ -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<len; i++)
|
||||
{
|
||||
ccxInt16 c = m_sString[i];
|
||||
unsigned short c = m_sString[i];
|
||||
CCAssert( c < kCCBMFontMaxChars, "BitmapFontAtlas: character outside bounds");
|
||||
|
||||
if (c == '\n')
|
||||
|
|
|
@ -29,16 +29,6 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
// [u]int[8|16|32|64]
|
||||
// char
|
||||
typedef unsigned char ccxByte;
|
||||
typedef signed short ccxInt16;
|
||||
typedef unsigned short ccxUInt16;
|
||||
// int
|
||||
// unsigned
|
||||
typedef long long ccxInt64;
|
||||
typedef unsigned long long ccxUInt64;
|
||||
|
||||
/// The max length of CCLog message.
|
||||
static const int kMaxLogLen = 255;
|
||||
|
||||
|
@ -47,66 +37,6 @@ static const int kMaxLogLen = 255;
|
|||
*/
|
||||
void CC_DLL CCLog(const char * pszFormat, ...);
|
||||
|
||||
struct ccxNullDeleter { template< class TPTR > 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<D*>(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<D*>(this))(m_ptr); }
|
||||
|
||||
void reset(T * p = 0) { ccxScopedArray<T>(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__
|
||||
|
|
|
@ -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,11 +173,13 @@ 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;
|
||||
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
/* here we set up the standard libjpeg error handler */
|
||||
cinfo.err = jpeg_std_error( &jerr );
|
||||
|
||||
|
@ -194,7 +202,7 @@ bool CCImage::_initWithJpgData(void * data, int nSize)
|
|||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Start decompression jpeg here */
|
||||
|
@ -206,26 +214,29 @@ bool CCImage::_initWithJpgData(void * data, int nSize)
|
|||
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();
|
||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
||||
CC_BREAK_IF(! row_pointer[0]);
|
||||
|
||||
m_pData = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components];
|
||||
CC_BREAK_IF(! m_pData);
|
||||
|
||||
/* now actually read the jpeg into the raw buffer */
|
||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
||||
|
||||
/* 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<cinfo.image_width*cinfo.num_components;i++)
|
||||
pData[location++] = row_pointer[0][i];
|
||||
m_pData[location++] = row_pointer[0][i];
|
||||
}
|
||||
|
||||
/* wrap up decompression, destroy objects, free pointers and close open files */
|
||||
jpeg_finish_decompress( &cinfo );
|
||||
jpeg_destroy_decompress( &cinfo );
|
||||
delete row_pointer[0];
|
||||
/* wrap up decompression, destroy objects, free pointers and close open files */
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
return true;
|
||||
CC_SAFE_DELETE_ARRAY(row_pointer[0]);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
||||
|
@ -234,6 +245,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
|||
png_byte header[8] = {0};
|
||||
png_structp png_ptr = 0;
|
||||
png_infop info_ptr = 0;
|
||||
unsigned char * pImateData = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -283,14 +295,16 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
|||
{
|
||||
bytesPerComponent = 4;
|
||||
}
|
||||
m_pData.reset(new ccxByte[nHeight * nWidth * bytesPerComponent]);
|
||||
pImateData = new unsigned char[nHeight * nWidth * bytesPerComponent];
|
||||
CC_BREAK_IF(! pImateData);
|
||||
|
||||
png_bytep * rowPointers = png_get_rows(png_ptr, info_ptr);
|
||||
|
||||
// copy data to image info
|
||||
int bytesPerRow = nWidth * bytesPerComponent;
|
||||
if(m_bHasAlpha)
|
||||
{
|
||||
unsigned int *tmp = (unsigned int *)m_pData.get();
|
||||
unsigned int *tmp = (unsigned int *)pImateData;
|
||||
for(unsigned int i = 0; i < nHeight; i++)
|
||||
{
|
||||
for(int j = 0; j < bytesPerRow; j += 4)
|
||||
|
@ -304,16 +318,20 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
|||
{
|
||||
for (unsigned int j = 0; j < nHeight; ++j)
|
||||
{
|
||||
memcpy(m_pData.get() + j * bytesPerRow, rowPointers[j], bytesPerRow);
|
||||
memcpy(pImateData + j * bytesPerRow, rowPointers[j], bytesPerRow);
|
||||
}
|
||||
}
|
||||
|
||||
m_nHeight = (ccxInt16)nHeight;
|
||||
m_nWidth = (ccxInt16)nWidth;
|
||||
m_nBitsPerComponent = nBitsPerComponent;
|
||||
m_nHeight = (short)nHeight;
|
||||
m_nWidth = (short)nWidth;
|
||||
m_pData = pImateData;
|
||||
pImateData = 0;
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(pImateData);
|
||||
|
||||
if (png_ptr)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, (info_ptr) ? &info_ptr : 0, 0);
|
||||
|
|
|
@ -33,6 +33,7 @@ class CC_DLL CCImage
|
|||
{
|
||||
public:
|
||||
CCImage();
|
||||
~CCImage();
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ public:
|
|||
const char * pFontName = 0,
|
||||
int nSize = 0);
|
||||
|
||||
ccxByte * getData() { return m_pData.get(); }
|
||||
unsigned char * getData() { return m_pData; }
|
||||
int getDataLen() { return m_nWidth * m_nHeight; }
|
||||
int getColorSpace() { return 1; }
|
||||
|
||||
|
@ -102,8 +103,8 @@ public:
|
|||
*/
|
||||
bool saveToFile(const char * pszFilePath) { return false; }
|
||||
|
||||
CC_SYNTHESIZE_READONLY(ccxInt16, m_nWidth, Width);
|
||||
CC_SYNTHESIZE_READONLY(ccxInt16, m_nHeight, Height);
|
||||
CC_SYNTHESIZE_READONLY(short, m_nWidth, Width);
|
||||
CC_SYNTHESIZE_READONLY(short, m_nHeight, Height);
|
||||
CC_SYNTHESIZE_READONLY(int, m_nBitsPerComponent, BitsPerComponent);
|
||||
|
||||
public:
|
||||
|
@ -117,7 +118,7 @@ protected:
|
|||
bool _initWithJpgData(void * pData, int nDatalen);
|
||||
bool _initWithPngData(void * pData, int nDatalen);
|
||||
|
||||
ccxScopedArray<ccxByte> m_pData;
|
||||
unsigned char * m_pData;
|
||||
bool m_bHasAlpha;
|
||||
bool m_bPreMulti;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
class Impl;
|
||||
ccxScopedPtr<CCLock::Impl> m_pImp;
|
||||
CCLock::Impl * m_pImp;
|
||||
};
|
||||
#else // CC_SUPPORT_MULTITHREAD
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -52,10 +52,7 @@ CCLock::CCLock()
|
|||
|
||||
CCLock::~CCLock()
|
||||
{
|
||||
if (m_pImp)
|
||||
{
|
||||
delete m_pImp;
|
||||
}
|
||||
CC_SAFE_DELETE(m_pImp);
|
||||
}
|
||||
|
||||
void CCLock::lock()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -46,6 +46,7 @@ CCXLock::CCXLock()
|
|||
|
||||
CCXLock::~CCXLock()
|
||||
{
|
||||
CC_SAFE_DELETE(m_pImp);
|
||||
}
|
||||
|
||||
void CCXLock::lock()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,6 +58,7 @@ CCLock::CCLock()
|
|||
|
||||
CCLock::~CCLock()
|
||||
{
|
||||
CC_SAFE_DELETE(m_pImp);
|
||||
}
|
||||
|
||||
void CCLock::lock()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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; y<image->getHeight(); ++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; y<image->getHeight(); ++y)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue