cocos2d-x  2.2.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCImage Class Reference

#include <CCImage.h>

Inheritance diagram for CCImage:
CCObject CCCopying

Public Types

enum  EImageFormat {
  kFmtJpg = 0, kFmtPng, kFmtTiff, kFmtWebp,
  kFmtRawData, kFmtUnKnown
}
 
enum  ETextAlign {
  kAlignCenter = 0x33, kAlignTop = 0x13, kAlignTopRight = 0x12, kAlignRight = 0x32,
  kAlignBottomRight = 0x22, kAlignBottom = 0x23, kAlignBottomLeft = 0x21, kAlignLeft = 0x31,
  kAlignTopLeft = 0x11
}
 

Public Member Functions

 CCImage ()
 ctor ()
 CCImage ()
 ~CCImage ()
bool initWithImageFile (const char *strPath, EImageFormat imageType=kFmtPng)
 Load the image from the specified path. More...
 
var initWithImageFile ( var strPath, var kFmtPng)
 Load the image from the specified path. More...
 
local initWithImageFile ( local strPath, local kFmtPng)
 Load the image from the specified path. More...
 
bool initWithImageFileThreadSafe (const char *fullpath, EImageFormat imageType=kFmtPng)
var initWithImageFileThreadSafe ( var fullpath, var kFmtPng)
local initWithImageFileThreadSafe ( local fullpath, local kFmtPng)
bool initWithImageData (void *pData, int nDataLen, EImageFormat eFmt=kFmtUnKnown, int nWidth=0, int nHeight=0, int nBitsPerComponent=8)
 Load image from stream buffer. More...
 
local initWithImageData ( local pData, local nDataLen, local kFmtUnKnown, local 0, local 0, local 8)
 Load image from stream buffer. More...
 
bool initWithString (const char *pText, int nWidth=0, int nHeight=0, ETextAlign eAlignMask=kAlignCenter, const char *pFontName=0, int nSize=0)
 Create image with specified string. More...
 
local initWithString ( local pText, local 0, local 0, local kAlignCenter, local 0, local 0)
 Create image with specified string. More...
 
bool initWithStringShadowStroke (const char *pText, int nWidth=0, int nHeight=0, ETextAlign eAlignMask=kAlignCenter, const char *pFontName=0, int nSize=0, float textTintR=1, float textTintG=1, float textTintB=1, bool shadow=false, float shadowOffsetX=0.0, float shadowOffsetY=0.0, float shadowOpacity=0.0, float shadowBlur=0.0, bool stroke=false, float strokeR=1, float strokeG=1, float strokeB=1, float strokeSize=1)
unsigned char * getData ()
int getDataLen ()
var getDataLen ()
local getDataLen ()
bool hasAlpha ()
var hasAlpha ()
local hasAlpha ()
bool isPremultipliedAlpha ()
var isPremultipliedAlpha ()
local isPremultipliedAlpha ()
bool saveToFile (const char *pszFilePath, bool bIsToRGB=true)
 Save CCImage data to the specified file, with specified format. More...
 
var saveToFile ( var pszFilePath, var true)
 Save CCImage data to the specified file, with specified format. More...
 
local saveToFile ( local pszFilePath, local true)
 Save CCImage data to the specified file, with specified format. More...
 
virtual unsigned short getWidth (void)
 getWidth More...
 
virtual unsigned short getHeight (void)
 getHeight More...
 
local getHeight ()
 getHeight More...
 
virtual int getBitsPerComponent (void)
 getBitsPerComponent More...
 
local getBitsPerComponent ()
 getBitsPerComponent More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Protected Member Functions

bool _initWithJpgData (void *pData, int nDatalen)
local _initWithJpgData ( local pData, local nDatalen)
bool _initWithPngData (void *pData, int nDatalen)
var _initWithPngData ( var pData, var nDatalen)
local _initWithPngData ( local pData, local nDatalen)
bool _initWithTiffData (void *pData, int nDataLen)
var _initWithTiffData ( var pData, var nDataLen)
local _initWithTiffData ( local pData, local nDataLen)
bool _initWithWebpData (void *pData, int nDataLen)
var _initWithWebpData ( var pData, var nDataLen)
local _initWithWebpData ( local pData, local nDataLen)
bool _initWithRawData (void *pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
var _initWithRawData ( var pData, var nDatalen, var nWidth, var nHeight, var nBitsPerComponent, var bPreMulti)
local _initWithRawData ( local pData, local nDatalen, local nWidth, local nHeight, local nBitsPerComponent, local bPreMulti)
bool _saveImageToPNG (const char *pszFilePath, bool bIsToRGB=true)
var _saveImageToPNG ( var pszFilePath, var true)
local _saveImageToPNG ( local pszFilePath, local true)
bool _saveImageToJPG (const char *pszFilePath)
var _saveImageToJPG ( var pszFilePath)
local _saveImageToJPG ( local pszFilePath)

Protected Attributes

unsigned short m_nWidth
unsigned short m_nHeight
int m_nBitsPerComponent
unsigned char * m_pData
bool m_bHasAlpha
var m_bHasAlpha
local m_bHasAlpha
bool m_bPreMulti
var m_bPreMulti
local m_bPreMulti
CCFreeTypeFontm_ft
var m_ft
local m_ft
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Member Enumeration Documentation

Enumerator
kFmtJpg 
kFmtPng 
kFmtTiff 
kFmtWebp 
kFmtRawData 
kFmtUnKnown 
Enumerator
kFmtJpg 
kFmtPng 
kFmtTiff 
kFmtWebp 
kFmtRawData 
kFmtUnKnown 
local EImageFormat
Enumerator
kFmtJpg 
kFmtPng 
kFmtTiff 
kFmtWebp 
kFmtRawData 
kFmtUnKnown 
enum ETextAlign
Enumerator
kAlignCenter 

Horizontal center and vertical center.

kAlignTop 

Horizontal center and vertical top.

kAlignTopRight 

Horizontal right and vertical top.

kAlignRight 

Horizontal right and vertical center.

kAlignBottomRight 

Horizontal right and vertical bottom.

kAlignBottom 

Horizontal center and vertical bottom.

kAlignBottomLeft 

Horizontal left and vertical bottom.

kAlignLeft 

Horizontal left and vertical center.

kAlignTopLeft 

Horizontal left and vertical top.

Enumerator
kAlignCenter 

Horizontal center and vertical center.

kAlignTop 

Horizontal center and vertical top.

kAlignTopRight 

Horizontal right and vertical top.

kAlignRight 

Horizontal right and vertical center.

kAlignBottomRight 

Horizontal right and vertical bottom.

kAlignBottom 

Horizontal center and vertical bottom.

kAlignBottomLeft 

Horizontal left and vertical bottom.

kAlignLeft 

Horizontal left and vertical center.

kAlignTopLeft 

Horizontal left and vertical top.

local ETextAlign
Enumerator
kAlignCenter 

Horizontal center and vertical center.

kAlignTop 

Horizontal center and vertical top.

kAlignTopRight 

Horizontal right and vertical top.

kAlignRight 

Horizontal right and vertical center.

kAlignBottomRight 

Horizontal right and vertical bottom.

kAlignBottom 

Horizontal center and vertical bottom.

kAlignBottomLeft 

Horizontal left and vertical bottom.

kAlignLeft 

Horizontal left and vertical center.

kAlignTopLeft 

Horizontal left and vertical top.

Constructor & Destructor Documentation

CCImage ( )
var ctor ( )
local CCImage ( )
~CCImage ( )

Member Function Documentation

bool _initWithJpgData ( void *  pData,
int  nDatalen 
)
protected
var _initWithJpgData ( var  pData,
var  nDatalen 
)
protected
local _initWithJpgData ( local  pData,
local  nDatalen 
)
protected
bool _initWithPngData ( void *  pData,
int  nDatalen 
)
protected
var _initWithPngData ( var  pData,
var  nDatalen 
)
protected
local _initWithPngData ( local  pData,
local  nDatalen 
)
protected
bool _initWithRawData ( void *  pData,
int  nDatalen,
int  nWidth,
int  nHeight,
int  nBitsPerComponent,
bool  bPreMulti 
)
protected
var _initWithRawData ( var  pData,
var  nDatalen,
var  nWidth,
var  nHeight,
var  nBitsPerComponent,
var  bPreMulti 
)
protected
local _initWithRawData ( local  pData,
local  nDatalen,
local  nWidth,
local  nHeight,
local  nBitsPerComponent,
local  bPreMulti 
)
protected
bool _initWithTiffData ( void *  pData,
int  nDataLen 
)
protected
var _initWithTiffData ( var  pData,
var  nDataLen 
)
protected
local _initWithTiffData ( local  pData,
local  nDataLen 
)
protected
bool _initWithWebpData ( void *  pData,
int  nDataLen 
)
protected
var _initWithWebpData ( var  pData,
var  nDataLen 
)
protected
local _initWithWebpData ( local  pData,
local  nDataLen 
)
protected
bool _saveImageToJPG ( const char *  pszFilePath)
protected
var _saveImageToJPG ( var  pszFilePath)
protected
local _saveImageToJPG ( local  pszFilePath)
protected
bool _saveImageToPNG ( const char *  pszFilePath,
bool  bIsToRGB = true 
)
protected
var _saveImageToPNG ( var  pszFilePath,
var  bIsToRGB = true 
)
protected
local _saveImageToPNG ( local  pszFilePath,
local  bIsToRGB = true 
)
protected
virtual int getBitsPerComponent ( void  )
virtual

getBitsPerComponent

var getBitsPerComponent (   )
virtual

getBitsPerComponent

local getBitsPerComponent (   )
virtual

getBitsPerComponent

unsigned char* getData ( )
inline
var getData ( )
inline
local getData ( )
inline
int getDataLen ( )
inline
var getDataLen ( )
inline
local getDataLen ( )
inline
virtual unsigned short getHeight ( void  )
virtual

getHeight

var getHeight (   )
virtual

getHeight

local getHeight (   )
virtual

getHeight

virtual unsigned short getWidth ( void  )
virtual

getWidth

var getWidth (   )
virtual

getWidth

local getWidth (   )
virtual

getWidth

bool hasAlpha ( )
inline
var hasAlpha ( )
inline
local hasAlpha ( )
inline
bool initWithImageData ( void *  pData,
int  nDataLen,
EImageFormat  eFmt = kFmtUnKnown,
int  nWidth = 0,
int  nHeight = 0,
int  nBitsPerComponent = 8 
)

Load image from stream buffer.

Warning
kFmtRawData only supports RGBA8888.
Parameters
pBufferstream buffer which holds the image data.
nLengthdata length expressed in (number of) bytes.
nWidth,nHeight,nBitsPerComponentare used for kFmtRawData.
Returns
true if loaded correctly.
local initWithImageData ( local  pData,
local  nDataLen,
local  eFmt = kFmtUnKnown,
local  nWidth = 0,
local  nHeight = 0,
local  nBitsPerComponent = 8 
)

Load image from stream buffer.

Warning
kFmtRawData only supports RGBA8888.
Parameters
pBufferstream buffer which holds the image data.
nLengthdata length expressed in (number of) bytes.
nWidth,nHeight,nBitsPerComponentare used for kFmtRawData.
Returns
true if loaded correctly.
bool initWithImageFile ( const char *  strPath,
EImageFormat  imageType = kFmtPng 
)

Load the image from the specified path.

Parameters
strPaththe absolute file path.
imageTypethe type of image, currently only supporting two types.
Returns
true if loaded correctly.
var initWithImageFile ( var  strPath,
var  imageType = kFmtPng 
)

Load the image from the specified path.

Parameters
strPaththe absolute file path.
imageTypethe type of image, currently only supporting two types.
Returns
true if loaded correctly.
local initWithImageFile ( local  strPath,
local  imageType = kFmtPng 
)

Load the image from the specified path.

Parameters
strPaththe absolute file path.
imageTypethe type of image, currently only supporting two types.
Returns
true if loaded correctly.
bool initWithImageFileThreadSafe ( const char *  fullpath,
EImageFormat  imageType = kFmtPng 
)
var initWithImageFileThreadSafe ( var  fullpath,
var  imageType = kFmtPng 
)
local initWithImageFileThreadSafe ( local  fullpath,
local  imageType = kFmtPng 
)
bool initWithString ( const char *  pText,
int  nWidth = 0,
int  nHeight = 0,
ETextAlign  eAlignMask = kAlignCenter,
const char *  pFontName = 0,
int  nSize = 0 
)

Create image with specified string.

Parameters
pTextthe text the image will show (cannot be nil).
nWidththe image width, if 0, the width will match the text's width.
nHeightthe image height, if 0, the height will match the text's height.
eAlignMaskthe test Alignment
pFontNamethe name of the font used to draw the text. If nil, use the default system font.
nSizethe font size, if 0, use the system default size.
local initWithString ( local  pText,
local  nWidth = 0,
local  nHeight = 0,
local  eAlignMask = kAlignCenter,
local  pFontName = 0,
local  nSize = 0 
)

Create image with specified string.

Parameters
pTextthe text the image will show (cannot be nil).
nWidththe image width, if 0, the width will match the text's width.
nHeightthe image height, if 0, the height will match the text's height.
eAlignMaskthe test Alignment
pFontNamethe name of the font used to draw the text. If nil, use the default system font.
nSizethe font size, if 0, use the system default size.
bool initWithStringShadowStroke ( const char *  pText,
int  nWidth = 0,
int  nHeight = 0,
ETextAlign  eAlignMask = kAlignCenter,
const char *  pFontName = 0,
int  nSize = 0,
float  textTintR = 1,
float  textTintG = 1,
float  textTintB = 1,
bool  shadow = false,
float  shadowOffsetX = 0.0,
float  shadowOffsetY = 0.0,
float  shadowOpacity = 0.0,
float  shadowBlur = 0.0,
bool  stroke = false,
float  strokeR = 1,
float  strokeG = 1,
float  strokeB = 1,
float  strokeSize = 1 
)
bool isPremultipliedAlpha ( )
inline
var isPremultipliedAlpha ( )
inline
local isPremultipliedAlpha ( )
inline
bool saveToFile ( const char *  pszFilePath,
bool  bIsToRGB = true 
)

Save CCImage data to the specified file, with specified format.

Parameters
pszFilePaththe file's absolute path, including file suffix.
bIsToRGBwhether the image is saved as RGB format.
var saveToFile ( var  pszFilePath,
var  bIsToRGB = true 
)

Save CCImage data to the specified file, with specified format.

Parameters
pszFilePaththe file's absolute path, including file suffix.
bIsToRGBwhether the image is saved as RGB format.
local saveToFile ( local  pszFilePath,
local  bIsToRGB = true 
)

Save CCImage data to the specified file, with specified format.

Parameters
pszFilePaththe file's absolute path, including file suffix.
bIsToRGBwhether the image is saved as RGB format.

Member Data Documentation

bool m_bHasAlpha
protected
var m_bHasAlpha
protected
local m_bHasAlpha
protected
bool m_bPreMulti
protected
var m_bPreMulti
protected
local m_bPreMulti
protected
CCFreeTypeFont* m_ft
protected
var m_ft
protected
local m_ft
protected
int m_nBitsPerComponent
protected
var m_nBitsPerComponent
protected
local m_nBitsPerComponent
protected
unsigned short m_nHeight
protected
unsigned short m_nWidth
protected
unsigned char* m_pData
protected
var m_pData
protected
local m_pData
protected

The documentation for this class was generated from the following files: