cocos2d-x  3.0-alpha0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Image Class Reference

#include <CCImage.h>

Inheritance diagram for Image:
Object

Public Types

enum  Format {
  JPG, PNG, TIFF, WEBP,
  PVR, ETC, S3TC, ATITC,
  RAW_DATA, UNKOWN
}
 Supported formats for Image. More...
 
enum  TextAlign {
  CENTER = 0x33, TOP = 0x13, TOP_RIGHT = 0x12, RIGHT = 0x32,
  BOTTOM_RIGHT = 0x22, BOTTOM = 0x23, BOTTOM_LEFT = 0x21, LEFT = 0x31,
  TOP_LEFT = 0x11
}
 

Public Member Functions

 Image ()
virtual ~Image ()
bool initWithImageFile (const char *path)
 Load the image from the specified path. More...
 
bool initWithImageData (const unsigned char *data, int dataLen)
 Load image from stream buffer. More...
 
bool initWithRawData (const unsigned char *data, int dataLen, int width, int height, int bitsPerComponent, bool preMulti=false)
bool initWithString (const char *text, int width=0, int height=0, TextAlign alignMask=TextAlign::CENTER, const char *fontName=0, int size=0)
 Create image with specified string. More...
 
bool initWithStringShadowStroke (const char *pText, int nWidth=0, int nHeight=0, TextAlign eAlignMask=TextAlign::CENTER, 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 ()
Format getFileType ()
Texture2D::PixelFormat getRenderFormat ()
int getWidth ()
int getHeight ()
bool isPremultipliedAlpha ()
int getNumberOfMipmaps ()
MipmapInfogetMipmaps ()
bool hasPremultipliedAlpha ()
int getBitPerPixel ()
bool hasAlpha ()
bool isCompressed ()
bool saveToFile (const char *filePath, bool isToRGB=true)
 Save Image data to the specified file, with specified format. More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual void update (float dt)

Protected Member Functions

bool initWithJpgData (const unsigned char *data, int dataLen)
bool initWithPngData (const unsigned char *data, int dataLen)
bool initWithTiffData (const unsigned char *data, int dataLen)
bool initWithWebpData (const unsigned char *data, int dataLen)
bool initWithPVRData (const unsigned char *data, int dataLen)
bool initWithPVRv2Data (const unsigned char *data, int dataLen)
bool initWithPVRv3Data (const unsigned char *data, int dataLen)
bool initWithETCData (const unsigned char *data, int dataLen)
bool initWithS3TCData (const unsigned char *data, int dataLen)
bool initWithATITCData (const unsigned char *data, int dataLen)
bool saveImageToPNG (const char *filePath, bool isToRGB=true)
bool saveImageToJPG (const char *filePath)

Friends

class TextureCache

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
var _reference
 count of references More...
 
local _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 
var _autoReleaseCount
 count of autorelease More...
 
local _autoReleaseCount
 count of autorelease More...
 

Member Enumeration Documentation

enum Format
strong

Supported formats for Image.

Enumerator
JPG 

JPEG.

PNG 

PNG.

TIFF 

TIFF.

WEBP 

WebP.

PVR 

PVR.

ETC 

ETC.

S3TC 

S3TC.

ATITC 

ATITC.

RAW_DATA 

Raw Data.

UNKOWN 

Unknown format.

enum TextAlign
strong
Enumerator
CENTER 

Horizontal center and vertical center.

TOP 

Horizontal center and vertical top.

TOP_RIGHT 

Horizontal right and vertical top.

RIGHT 

Horizontal right and vertical center.

BOTTOM_RIGHT 

Horizontal right and vertical bottom.

BOTTOM 

Horizontal center and vertical bottom.

BOTTOM_LEFT 

Horizontal left and vertical bottom.

LEFT 

Horizontal left and vertical center.

TOP_LEFT 

Horizontal left and vertical top.

Constructor & Destructor Documentation

Image ( )
~Image ( )
virtual

Member Function Documentation

int getBitPerPixel ( )
unsigned char* getData ( )
inline
int getDataLen ( )
inline
Format getFileType ( )
inline
int getHeight ( )
inline
MipmapInfo* getMipmaps ( )
inline
int getNumberOfMipmaps ( )
inline
Texture2D::PixelFormat
getRenderFormat
( )
inline
int getWidth ( )
inline
bool hasAlpha ( )
bool hasPremultipliedAlpha ( )
inline
bool initWithATITCData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithETCData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithImageData ( const unsigned char *  data,
int  dataLen 
)

Load image from stream buffer.

Parameters
datastream buffer which holds the image data.
dataLendata length expressed in (number of) bytes.
Returns
true if loaded correctly.
bool initWithImageFile ( const char *  path)

Load the image from the specified path.

Parameters
paththe absolute file path.
Returns
true if loaded correctly.
bool initWithJpgData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithPngData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithPVRData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithPVRv2Data ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithPVRv3Data ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithRawData ( const unsigned char *  data,
int  dataLen,
int  width,
int  height,
int  bitsPerComponent,
bool  preMulti = false 
)
bool initWithS3TCData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithString ( const char *  text,
int  width = 0,
int  height = 0,
TextAlign  alignMask = TextAlign::CENTER,
const char *  fontName = 0,
int  size = 0 
)

Create image with specified string.

Parameters
textthe text the image will show (cannot be nil).
widththe image width, if 0, the width will match the text's width.
heightthe image height, if 0, the height will match the text's height.
alignMaskthe test Alignment
fontNamethe name of the font used to draw the text. If nil, use the default system font.
sizethe font size, if 0, use the system default size.
bool initWithStringShadowStroke ( const char *  pText,
int  nWidth = 0,
int  nHeight = 0,
TextAlign  eAlignMask = TextAlign::CENTER,
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 initWithTiffData ( const unsigned char *  data,
int  dataLen 
)
protected
bool initWithWebpData ( const unsigned char *  data,
int  dataLen 
)
protected
bool isCompressed ( )
bool isPremultipliedAlpha ( )
inline
bool saveImageToJPG ( const char *  filePath)
protected
bool saveImageToPNG ( const char *  filePath,
bool  isToRGB = true 
)
protected
bool saveToFile ( const char *  filePath,
bool  isToRGB = true 
)

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

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

Friends And Related Function Documentation

friend class TextureCache
friend

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