cocos2d-x  3.0alpha1
 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, long dataLen)
 Load image from stream buffer. More...
 
bool initWithRawData (const unsigned char *data, long dataLen, long width, long height, long 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)
var initWithStringShadowStroke ( var pText, var 0, var 0, var CENTER, var 0, var 0, var 1, var 1, var 1, var false, var 0, var 0, var 0, var 0, var false, var 1, var 1, var 1, var 1)
local initWithStringShadowStroke ( local pText, local 0, local 0, local CENTER, local 0, local 0, local 1, local 1, local 1, local false, local 0, local 0, local 0, local 0, local false, local 1, local 1, local 1, local 1)
unsigned char * getData ()
int getDataLen ()
Format getFileType ()
local getFileType ()
Texture2D::PixelFormat getRenderFormat ()
local getRenderFormat ()
int getWidth ()
int getHeight ()
bool isPremultipliedAlpha ()
var isPremultipliedAlpha ()
local isPremultipliedAlpha ()
int getNumberOfMipmaps ()
MipmapInfogetMipmaps ()
bool hasPremultipliedAlpha ()
local 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)
local initWithTiffData ( local data, local 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)
var initWithPVRv2Data ( var data, var dataLen)
local initWithPVRv2Data ( local data, local 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)
local initWithS3TCData ( local data, local 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...
 
unsigned int _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.

var 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.

local 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.

var 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.

local 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 ( )
var ctor ( )
local Image ( )
~Image ( )
virtual

Member Function Documentation

int getBitPerPixel ( )
var getBitPerPixel ( )
local getBitPerPixel ( )
unsigned char* getData ( )
inline
var getData ( )
inline
local getData ( )
inline
int getDataLen ( )
inline
var getDataLen ( )
inline
local getDataLen ( )
inline
Format getFileType ( )
inline
var getFileType ( )
inline
local getFileType ( )
inline
int getHeight ( )
inline
var getHeight ( )
inline
local getHeight ( )
inline
MipmapInfo* getMipmaps ( )
inline
var getMipmaps ( )
inline
local getMipmaps ( )
inline
int getNumberOfMipmaps ( )
inline
var getNumberOfMipmaps ( )
inline
local getNumberOfMipmaps ( )
inline
Texture2D::PixelFormat
getRenderFormat
( )
inline
var getRenderFormat ( )
inline
local getRenderFormat ( )
inline
int getWidth ( )
inline
var getWidth ( )
inline
local getWidth ( )
inline
bool hasAlpha ( )
var hasAlpha ( )
local hasAlpha ( )
bool hasPremultipliedAlpha ( )
inline
var hasPremultipliedAlpha ( )
inline
local hasPremultipliedAlpha ( )
inline
bool initWithATITCData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithATITCData ( var  data,
var  dataLen 
)
protected
local initWithATITCData ( local  data,
local  dataLen 
)
protected
bool initWithETCData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithETCData ( var  data,
var  dataLen 
)
protected
local initWithETCData ( local  data,
local  dataLen 
)
protected
bool initWithImageData ( const unsigned char *  data,
long  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
var initWithJpgData ( var  data,
var  dataLen 
)
protected
local initWithJpgData ( local  data,
local  dataLen 
)
protected
bool initWithPngData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithPngData ( var  data,
var  dataLen 
)
protected
local initWithPngData ( local  data,
local  dataLen 
)
protected
bool initWithPVRData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithPVRData ( var  data,
var  dataLen 
)
protected
local initWithPVRData ( local  data,
local  dataLen 
)
protected
bool initWithPVRv2Data ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithPVRv2Data ( var  data,
var  dataLen 
)
protected
local initWithPVRv2Data ( local  data,
local  dataLen 
)
protected
bool initWithPVRv3Data ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithPVRv3Data ( var  data,
var  dataLen 
)
protected
local initWithPVRv3Data ( local  data,
local  dataLen 
)
protected
bool initWithRawData ( const unsigned char *  data,
long  dataLen,
long  width,
long  height,
long  bitsPerComponent,
bool  preMulti = false 
)
var initWithRawData ( var  data,
var  dataLen,
var  width,
var  height,
var  bitsPerComponent,
var  preMulti = false 
)
local initWithRawData ( local  data,
local  dataLen,
local  width,
local  height,
local  bitsPerComponent,
local  preMulti = false 
)
bool initWithS3TCData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithS3TCData ( var  data,
var  dataLen 
)
protected
local initWithS3TCData ( local  data,
local  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 
)
var initWithStringShadowStroke ( var  pText,
var  nWidth = 0,
var  nHeight = 0,
var  eAlignMask = TextAlign::CENTER,
var  pFontName = 0,
var  nSize = 0,
var  textTintR = 1,
var  textTintG = 1,
var  textTintB = 1,
var  shadow = false,
var  shadowOffsetX = 0.0,
var  shadowOffsetY = 0.0,
var  shadowOpacity = 0.0,
var  shadowBlur = 0.0,
var  stroke = false,
var  strokeR = 1,
var  strokeG = 1,
var  strokeB = 1,
var  strokeSize = 1 
)
local initWithStringShadowStroke ( local  pText,
local  nWidth = 0,
local  nHeight = 0,
local  eAlignMask = TextAlign::CENTER,
local  pFontName = 0,
local  nSize = 0,
local  textTintR = 1,
local  textTintG = 1,
local  textTintB = 1,
local  shadow = false,
local  shadowOffsetX = 0.0,
local  shadowOffsetY = 0.0,
local  shadowOpacity = 0.0,
local  shadowBlur = 0.0,
local  stroke = false,
local  strokeR = 1,
local  strokeG = 1,
local  strokeB = 1,
local  strokeSize = 1 
)
bool initWithTiffData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithTiffData ( var  data,
var  dataLen 
)
protected
local initWithTiffData ( local  data,
local  dataLen 
)
protected
bool initWithWebpData ( const unsigned char *  data,
int  dataLen 
)
protected
var initWithWebpData ( var  data,
var  dataLen 
)
protected
local initWithWebpData ( local  data,
local  dataLen 
)
protected
bool isCompressed ( )
var isCompressed ( )
local isCompressed ( )
bool isPremultipliedAlpha ( )
inline
var isPremultipliedAlpha ( )
inline
local isPremultipliedAlpha ( )
inline
bool saveImageToJPG ( const char *  filePath)
protected
var saveImageToJPG ( var  filePath)
protected
local saveImageToJPG ( local  filePath)
protected
bool saveImageToPNG ( const char *  filePath,
bool  isToRGB = true 
)
protected
var saveImageToPNG ( var  filePath,
var  isToRGB = true 
)
protected
local saveImageToPNG ( local  filePath,
local  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.
var saveToFile ( var  filePath,
var  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.
local saveToFile ( local  filePath,
local  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
var TextureCache
friend
local TextureCache
friend

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