mirror of https://github.com/axmolengine/axmol.git
issue #396 win32 modifyed.
This commit is contained in:
parent
2015e468ca
commit
4b86cec4be
|
@ -433,7 +433,7 @@ namespace cocos2d{
|
||||||
{
|
{
|
||||||
int nextFontPositionX = 0;
|
int nextFontPositionX = 0;
|
||||||
int nextFontPositionY = 0;
|
int nextFontPositionY = 0;
|
||||||
ccxInt16 prev = -1;
|
unsigned short prev = -1;
|
||||||
int kerningAmount = 0;
|
int kerningAmount = 0;
|
||||||
|
|
||||||
CCSize tmpSize = CCSizeZero;
|
CCSize tmpSize = CCSizeZero;
|
||||||
|
@ -452,7 +452,7 @@ namespace cocos2d{
|
||||||
|
|
||||||
for (int i = 0; i < len - 1; ++i)
|
for (int i = 0; i < len - 1; ++i)
|
||||||
{
|
{
|
||||||
ccxInt16 c = m_sString[i];
|
unsigned short c = m_sString[i];
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
quantityOfLines++;
|
quantityOfLines++;
|
||||||
|
@ -464,7 +464,7 @@ namespace cocos2d{
|
||||||
|
|
||||||
for(int i=0; i<len; i++)
|
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");
|
CCAssert( c < kCCBMFontMaxChars, "BitmapFontAtlas: character outside bounds");
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
|
|
@ -29,16 +29,6 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN;
|
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.
|
/// The max length of CCLog message.
|
||||||
static const int kMaxLogLen = 255;
|
static const int kMaxLogLen = 255;
|
||||||
|
|
||||||
|
@ -47,66 +37,6 @@ static const int kMaxLogLen = 255;
|
||||||
*/
|
*/
|
||||||
void CC_DLL CCLog(const char * pszFormat, ...);
|
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;
|
NS_CC_END;
|
||||||
|
|
||||||
#endif // __CC_COMMON_H__
|
#endif // __CC_COMMON_H__
|
||||||
|
|
|
@ -34,10 +34,10 @@ THE SOFTWARE.
|
||||||
#undef QGLOBAL_H
|
#undef QGLOBAL_H
|
||||||
|
|
||||||
#define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
|
#define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
|
||||||
(unsigned)(((unsigned)((ccxByte)(vr) * ((ccxByte)(va) + 1)) >> 8) | \
|
(unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \
|
||||||
((unsigned)((ccxByte)(vg) * ((ccxByte)(va) + 1) >> 8) << 8) | \
|
((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \
|
||||||
((unsigned)((ccxByte)(vb) * ((ccxByte)(va) + 1) >> 8) << 16) | \
|
((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \
|
||||||
((unsigned)(ccxByte)(va) << 24))
|
((unsigned)(unsigned char)(va) << 24))
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -73,12 +73,18 @@ CCImage::CCImage()
|
||||||
: m_nWidth(0)
|
: m_nWidth(0)
|
||||||
, m_nHeight(0)
|
, m_nHeight(0)
|
||||||
, m_nBitsPerComponent(0)
|
, m_nBitsPerComponent(0)
|
||||||
|
, m_pData(0)
|
||||||
, m_bHasAlpha(false)
|
, m_bHasAlpha(false)
|
||||||
, m_bPreMulti(false)
|
, m_bPreMulti(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCImage::~CCImage()
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE_ARRAY(m_pData);
|
||||||
|
}
|
||||||
|
|
||||||
bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
|
bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
@ -167,73 +173,79 @@ bool CCImage::_initWithJpgData(void * data, int nSize)
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
/* libjpeg data structure for storing one row, that is, scanline of an image */
|
/* 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 long location = 0;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
|
||||||
/* here we set up the standard libjpeg error handler */
|
bool bRet = false;
|
||||||
cinfo.err = jpeg_std_error( &jerr );
|
do
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
{
|
||||||
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 */
|
/* Start decompression jpeg here */
|
||||||
jpeg_start_decompress( &cinfo );
|
jpeg_start_decompress( &cinfo );
|
||||||
|
|
||||||
/* init image info */
|
/* init image info */
|
||||||
m_nWidth = cinfo.image_width;
|
m_nWidth = cinfo.image_width;
|
||||||
m_nHeight = cinfo.image_height;
|
m_nHeight = cinfo.image_height;
|
||||||
m_bHasAlpha = false;
|
m_bHasAlpha = false;
|
||||||
m_bPreMulti = false;
|
m_bPreMulti = false;
|
||||||
m_nBitsPerComponent = 8;
|
m_nBitsPerComponent = 8;
|
||||||
m_pData.reset(new ccxByte[cinfo.output_width*cinfo.output_height*cinfo.output_components]);
|
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
||||||
ccxByte * pData = m_pData.get();
|
CC_BREAK_IF(! row_pointer[0]);
|
||||||
|
|
||||||
/* now actually read the jpeg into the raw buffer */
|
m_pData = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components];
|
||||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
CC_BREAK_IF(! m_pData);
|
||||||
|
|
||||||
/* read one scan line at a time */
|
/* now actually read the jpeg into the raw buffer */
|
||||||
while( cinfo.output_scanline < cinfo.image_height )
|
/* 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++)
|
jpeg_read_scanlines( &cinfo, row_pointer, 1 );
|
||||||
pData[location++] = row_pointer[0][i];
|
for( i=0; i<cinfo.image_width*cinfo.num_components;i++)
|
||||||
}
|
m_pData[location++] = row_pointer[0][i];
|
||||||
|
}
|
||||||
|
|
||||||
/* wrap up decompression, destroy objects, free pointers and close open files */
|
jpeg_finish_decompress( &cinfo );
|
||||||
jpeg_finish_decompress( &cinfo );
|
jpeg_destroy_decompress( &cinfo );
|
||||||
jpeg_destroy_decompress( &cinfo );
|
/* wrap up decompression, destroy objects, free pointers and close open files */
|
||||||
delete row_pointer[0];
|
bRet = true;
|
||||||
|
} while (0);
|
||||||
|
|
||||||
return true;
|
CC_SAFE_DELETE_ARRAY(row_pointer[0]);
|
||||||
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
png_byte header[8] = {0};
|
png_byte header[8] = {0};
|
||||||
png_structp png_ptr = 0;
|
png_structp png_ptr = 0;
|
||||||
png_infop info_ptr = 0;
|
png_infop info_ptr = 0;
|
||||||
|
unsigned char * pImateData = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -283,14 +295,16 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
||||||
{
|
{
|
||||||
bytesPerComponent = 4;
|
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);
|
png_bytep * rowPointers = png_get_rows(png_ptr, info_ptr);
|
||||||
|
|
||||||
// copy data to image info
|
// copy data to image info
|
||||||
int bytesPerRow = nWidth * bytesPerComponent;
|
int bytesPerRow = nWidth * bytesPerComponent;
|
||||||
if(m_bHasAlpha)
|
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(unsigned int i = 0; i < nHeight; i++)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < bytesPerRow; j += 4)
|
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)
|
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_nBitsPerComponent = nBitsPerComponent;
|
||||||
m_nWidth = (ccxInt16)nWidth;
|
m_nHeight = (short)nHeight;
|
||||||
m_nBitsPerComponent = nBitsPerComponent;
|
m_nWidth = (short)nWidth;
|
||||||
|
m_pData = pImateData;
|
||||||
|
pImateData = 0;
|
||||||
bRet = true;
|
bRet = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
CC_SAFE_DELETE_ARRAY(pImateData);
|
||||||
|
|
||||||
if (png_ptr)
|
if (png_ptr)
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, (info_ptr) ? &info_ptr : 0, 0);
|
png_destroy_read_struct(&png_ptr, (info_ptr) ? &info_ptr : 0, 0);
|
||||||
|
|
|
@ -33,6 +33,7 @@ class CC_DLL CCImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCImage();
|
CCImage();
|
||||||
|
~CCImage();
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -88,7 +89,7 @@ public:
|
||||||
const char * pFontName = 0,
|
const char * pFontName = 0,
|
||||||
int nSize = 0);
|
int nSize = 0);
|
||||||
|
|
||||||
ccxByte * getData() { return m_pData.get(); }
|
unsigned char * getData() { return m_pData; }
|
||||||
int getDataLen() { return m_nWidth * m_nHeight; }
|
int getDataLen() { return m_nWidth * m_nHeight; }
|
||||||
int getColorSpace() { return 1; }
|
int getColorSpace() { return 1; }
|
||||||
|
|
||||||
|
@ -102,8 +103,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool saveToFile(const char * pszFilePath) { return false; }
|
bool saveToFile(const char * pszFilePath) { return false; }
|
||||||
|
|
||||||
CC_SYNTHESIZE_READONLY(ccxInt16, m_nWidth, Width);
|
CC_SYNTHESIZE_READONLY(short, m_nWidth, Width);
|
||||||
CC_SYNTHESIZE_READONLY(ccxInt16, m_nHeight, Height);
|
CC_SYNTHESIZE_READONLY(short, m_nHeight, Height);
|
||||||
CC_SYNTHESIZE_READONLY(int, m_nBitsPerComponent, BitsPerComponent);
|
CC_SYNTHESIZE_READONLY(int, m_nBitsPerComponent, BitsPerComponent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -117,7 +118,7 @@ protected:
|
||||||
bool _initWithJpgData(void * pData, int nDatalen);
|
bool _initWithJpgData(void * pData, int nDatalen);
|
||||||
bool _initWithPngData(void * pData, int nDatalen);
|
bool _initWithPngData(void * pData, int nDatalen);
|
||||||
|
|
||||||
ccxScopedArray<ccxByte> m_pData;
|
unsigned char * m_pData;
|
||||||
bool m_bHasAlpha;
|
bool m_bHasAlpha;
|
||||||
bool m_bPreMulti;
|
bool m_bPreMulti;
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,7 @@ bool CCImage::initWithString(
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
unsigned char * pImageData = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(! pText);
|
CC_BREAK_IF(! pText);
|
||||||
|
@ -289,8 +290,8 @@ bool CCImage::initWithString(
|
||||||
SIZE size = {nWidth, nHeight};
|
SIZE size = {nWidth, nHeight};
|
||||||
CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask));
|
CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask));
|
||||||
|
|
||||||
m_pData.reset(new ccxByte[size.cx * size.cy * 4]);
|
pImageData = new unsigned char[size.cx * size.cy * 4];
|
||||||
CC_BREAK_IF(! m_pData.get());
|
CC_BREAK_IF(! pImageData);
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -301,23 +302,24 @@ bool CCImage::initWithString(
|
||||||
CC_BREAK_IF(! GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0,
|
CC_BREAK_IF(! GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0,
|
||||||
NULL, (LPBITMAPINFO)&bi, DIB_RGB_COLORS));
|
NULL, (LPBITMAPINFO)&bi, DIB_RGB_COLORS));
|
||||||
|
|
||||||
m_nWidth = (ccxInt16)size.cx;
|
m_nWidth = (short)size.cx;
|
||||||
m_nHeight = (ccxInt16)size.cy;
|
m_nHeight = (short)size.cy;
|
||||||
m_bHasAlpha = true;
|
m_bHasAlpha = true;
|
||||||
m_bPreMulti = false;
|
m_bPreMulti = false;
|
||||||
|
m_pData = pImageData;
|
||||||
|
pImageData = 0;
|
||||||
m_nBitsPerComponent = 8;
|
m_nBitsPerComponent = 8;
|
||||||
|
|
||||||
// copy pixed data
|
// copy pixed data
|
||||||
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0)
|
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0)
|
||||||
? - bi.bmiHeader.biHeight : bi.bmiHeader.biHeight;
|
? - 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);
|
(LPBITMAPINFO)&bi, DIB_RGB_COLORS);
|
||||||
|
|
||||||
// change pixel's alpha value to 255, when it's RGB != 0
|
// change pixel's alpha value to 255, when it's RGB != 0
|
||||||
COLORREF * pPixel = NULL;
|
COLORREF * pPixel = NULL;
|
||||||
for (int y = 0; y < m_nHeight; ++y)
|
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)
|
for (int x = 0; x < m_nWidth; ++x)
|
||||||
{
|
{
|
||||||
COLORREF& clr = *pPixel;
|
COLORREF& clr = *pPixel;
|
||||||
|
|
|
@ -432,21 +432,21 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in
|
||||||
// info = kCGImageAlphaOnly;
|
// info = kCGImageAlphaOnly;
|
||||||
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
|
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
|
||||||
|
|
||||||
tempData = (ccxByte*)(image->getData());
|
tempData = (unsigned char*)(image->getData());
|
||||||
CCAssert(tempData != NULL, "NULL image data.");
|
CCAssert(tempData != NULL, "NULL image data.");
|
||||||
|
|
||||||
if(image->getWidth() == POTWide && image->getHeight() == POTHigh)
|
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);
|
memcpy(data, tempData, POTHigh * POTWide * 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = new ccxByte[POTHigh * POTWide * 4];
|
data = new unsigned char[POTHigh * POTWide * 4];
|
||||||
memset(data, 0, POTHigh * POTWide * 4);
|
memset(data, 0, POTHigh * POTWide * 4);
|
||||||
|
|
||||||
ccxByte* pPixelData = (ccxByte*) tempData;
|
unsigned char* pPixelData = (unsigned char*) tempData;
|
||||||
ccxByte* pTargetData = (ccxByte*) data;
|
unsigned char* pTargetData = (unsigned char*) data;
|
||||||
|
|
||||||
for(int y=0; y<image->getHeight(); ++y)
|
for(int y=0; y<image->getHeight(); ++y)
|
||||||
{
|
{
|
||||||
|
@ -456,20 +456,20 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case kCCTexture2DPixelFormat_RGB888:
|
case kCCTexture2DPixelFormat_RGB888:
|
||||||
tempData = (ccxByte*)(image->getData());
|
tempData = (unsigned char*)(image->getData());
|
||||||
CCAssert(tempData != NULL, "NULL image data.");
|
CCAssert(tempData != NULL, "NULL image data.");
|
||||||
if(image->getWidth() == POTWide && image->getHeight() == POTHigh)
|
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);
|
memcpy(data, tempData, POTHigh * POTWide * 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = new ccxByte[POTHigh * POTWide * 3];
|
data = new unsigned char[POTHigh * POTWide * 3];
|
||||||
memset(data, 0, POTHigh * POTWide * 3);
|
memset(data, 0, POTHigh * POTWide * 3);
|
||||||
|
|
||||||
ccxByte* pPixelData = (ccxByte*) tempData;
|
unsigned char* pPixelData = (unsigned char*) tempData;
|
||||||
ccxByte* pTargetData = (ccxByte*) data;
|
unsigned char* pTargetData = (unsigned char*) data;
|
||||||
|
|
||||||
for(int y=0; y<image->getHeight(); ++y)
|
for(int y=0; y<image->getHeight(); ++y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue