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

#include <CCImage.h>

Inheritance diagram for Image:
Ref

Public Types

enum  Format {
  JPG, PNG, TIFF, WEBP,
  PVR, ETC, S3TC, ATITC,
  TGA, RAW_DATA, UNKOWN
}
 Supported formats for Image. More...
 

Public Member Functions

 Image ()
virtual ~Image ()
bool initWithImageFile (const std::string &path)
 Load the image from the specified path. More...
 
bool initWithImageData (const unsigned char *data, ssize_t dataLen)
 Load image from stream buffer. More...
 
bool initWithRawData (const unsigned char *data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti=false)
unsigned char * getData ()
ssize_t getDataLen ()
Format 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 std::string &filename, bool isToRGB=true)
 Save Image data to the specified file, with specified format. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Release the ownership immediately. More...
 
Refautorelease ()
 Release the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Protected Types

typedef struct sImageTGA tImageTGA

Protected Member Functions

bool initWithJpgData (const unsigned char *data, ssize_t dataLen)
bool initWithPngData (const unsigned char *data, ssize_t dataLen)
bool initWithTiffData (const unsigned char *data, ssize_t dataLen)
local initWithTiffData ( local data, local dataLen)
bool initWithWebpData (const unsigned char *data, ssize_t dataLen)
bool initWithPVRData (const unsigned char *data, ssize_t dataLen)
bool initWithPVRv2Data (const unsigned char *data, ssize_t dataLen)
local initWithPVRv2Data ( local data, local dataLen)
bool initWithPVRv3Data (const unsigned char *data, ssize_t dataLen)
bool initWithETCData (const unsigned char *data, ssize_t dataLen)
bool initWithS3TCData (const unsigned char *data, ssize_t dataLen)
bool initWithATITCData (const unsigned char *data, ssize_t dataLen)
bool initWithTGAData (tImageTGA *tgaData)
bool saveImageToPNG (const std::string &filePath, bool isToRGB=true)
bool saveImageToJPG (const std::string &filePath)
 Image (const Image &rImg)
Imageoperator= (const Image &)
bool initWithImageFileThreadSafe (const std::string &fullpath)
local initWithImageFileThreadSafe ( local fullpath)
Format detectFormat (const unsigned char *data, ssize_t dataLen)
bool isPng (const unsigned char *data, ssize_t dataLen)
bool isJpg (const unsigned char *data, ssize_t dataLen)
bool isTiff (const unsigned char *data, ssize_t dataLen)
bool isWebp (const unsigned char *data, ssize_t dataLen)
bool isPvr (const unsigned char *data, ssize_t dataLen)
bool isEtc (const unsigned char *data, ssize_t dataLen)
bool isS3TC (const unsigned char *data, ssize_t dataLen)
bool isATITC (const unsigned char *data, ssize_t dataLen)
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Protected Attributes

unsigned char * _data
var _data
local _data
ssize_t _dataLen
var _dataLen
local _dataLen
int _width
int _height
var _height
local _height
Format _fileType
var _fileType
local _fileType
Texture2D::PixelFormat _renderFormat
var _renderFormat
local _renderFormat
bool _preMulti
MipmapInfo _mipmaps [MIPMAP_MAX]
int _numberOfMipmaps
var _numberOfMipmaps
local _numberOfMipmaps
bool _hasPremultipliedAlpha
var _hasPremultipliedAlpha
local _hasPremultipliedAlpha
std::string _filePath
var _filePath
local _filePath
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Static Protected Attributes

static const int MIPMAP_MAX = 16
 Determine how many mipmaps can we have. More...
 
local MIPMAP_MAX = 16
 Determine how many mipmaps can we have. More...
 

Friends

class TextureCache

Member Typedef Documentation

typedef struct sImageTGA tImageTGA
protected
var tImageTGA
protected
local tImageTGA
protected

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.

TGA 

TGA.

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.

TGA 

TGA.

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.

TGA 

TGA.

RAW_DATA 

Raw Data.

UNKOWN 

Unknown format.

Constructor & Destructor Documentation

Image ( )
var ctor ( )
local Image ( )
virtual ~Image ( )
virtual
Image ( const Image rImg)
protected
var Image ( var  rImg)
protected
local Image ( local  rImg)
protected

Member Function Documentation

Format detectFormat ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var detectFormat ( var  data,
var  dataLen 
)
protected
local detectFormat ( local  data,
local  dataLen 
)
protected
int getBitPerPixel ( )
var getBitPerPixel ( )
local getBitPerPixel ( )
unsigned char* getData ( )
inline
var getData ( )
inline
local getData ( )
inline
ssize_t 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,
ssize_t  dataLen 
)
protected
var initWithATITCData ( var  data,
var  dataLen 
)
protected
local initWithATITCData ( local  data,
local  dataLen 
)
protected
bool initWithETCData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithETCData ( var  data,
var  dataLen 
)
protected
local initWithETCData ( local  data,
local  dataLen 
)
protected
bool initWithImageData ( const unsigned char *  data,
ssize_t  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 std::string &  path)

Load the image from the specified path.

Parameters
paththe absolute file path.
Returns
true if loaded correctly.
bool initWithImageFileThreadSafe ( const std::string &  fullpath)
protected
var initWithImageFileThreadSafe ( var  fullpath)
protected
local initWithImageFileThreadSafe ( local  fullpath)
protected
bool initWithJpgData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithJpgData ( var  data,
var  dataLen 
)
protected
local initWithJpgData ( local  data,
local  dataLen 
)
protected
bool initWithPngData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithPngData ( var  data,
var  dataLen 
)
protected
local initWithPngData ( local  data,
local  dataLen 
)
protected
bool initWithPVRData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithPVRData ( var  data,
var  dataLen 
)
protected
local initWithPVRData ( local  data,
local  dataLen 
)
protected
bool initWithPVRv2Data ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithPVRv2Data ( var  data,
var  dataLen 
)
protected
local initWithPVRv2Data ( local  data,
local  dataLen 
)
protected
bool initWithPVRv3Data ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithPVRv3Data ( var  data,
var  dataLen 
)
protected
local initWithPVRv3Data ( local  data,
local  dataLen 
)
protected
bool initWithRawData ( const unsigned char *  data,
ssize_t  dataLen,
int  width,
int  height,
int  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,
ssize_t  dataLen 
)
protected
var initWithS3TCData ( var  data,
var  dataLen 
)
protected
local initWithS3TCData ( local  data,
local  dataLen 
)
protected
bool initWithTGAData ( tImageTGA tgaData)
protected
var initWithTGAData ( var  tgaData)
protected
local initWithTGAData ( local  tgaData)
protected
bool initWithTiffData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithTiffData ( var  data,
var  dataLen 
)
protected
local initWithTiffData ( local  data,
local  dataLen 
)
protected
bool initWithWebpData ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var initWithWebpData ( var  data,
var  dataLen 
)
protected
local initWithWebpData ( local  data,
local  dataLen 
)
protected
bool isATITC ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isATITC ( var  data,
var  dataLen 
)
protected
local isATITC ( local  data,
local  dataLen 
)
protected
bool isCompressed ( )
var isCompressed ( )
local isCompressed ( )
bool isEtc ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isEtc ( var  data,
var  dataLen 
)
protected
local isEtc ( local  data,
local  dataLen 
)
protected
bool isJpg ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isJpg ( var  data,
var  dataLen 
)
protected
local isJpg ( local  data,
local  dataLen 
)
protected
bool isPng ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isPng ( var  data,
var  dataLen 
)
protected
local isPng ( local  data,
local  dataLen 
)
protected
bool isPremultipliedAlpha ( )
inline
var isPremultipliedAlpha ( )
inline
local isPremultipliedAlpha ( )
inline
bool isPvr ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isPvr ( var  data,
var  dataLen 
)
protected
local isPvr ( local  data,
local  dataLen 
)
protected
bool isS3TC ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isS3TC ( var  data,
var  dataLen 
)
protected
local isS3TC ( local  data,
local  dataLen 
)
protected
bool isTiff ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isTiff ( var  data,
var  dataLen 
)
protected
local isTiff ( local  data,
local  dataLen 
)
protected
bool isWebp ( const unsigned char *  data,
ssize_t  dataLen 
)
protected
var isWebp ( var  data,
var  dataLen 
)
protected
local isWebp ( local  data,
local  dataLen 
)
protected
Image& operator= ( const Image )
protected
Image& operator= ( var  )
protected
Image& operator= ( local  )
protected
bool saveImageToJPG ( const std::string &  filePath)
protected
var saveImageToJPG ( var  filePath)
protected
local saveImageToJPG ( local  filePath)
protected
bool saveImageToPNG ( const std::string &  filePath,
bool  isToRGB = true 
)
protected
var saveImageToPNG ( var  filePath,
var  isToRGB = true 
)
protected
local saveImageToPNG ( local  filePath,
local  isToRGB = true 
)
protected
bool saveToFile ( const std::string &  filename,
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  filename,
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  filename,
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

Member Data Documentation

unsigned char* _data
protected
var _data
protected
local _data
protected
ssize_t _dataLen
protected
var _dataLen
protected
local _dataLen
protected
std::string _filePath
protected
var _filePath
protected
local _filePath
protected
Format _fileType
protected
var _fileType
protected
local _fileType
protected
bool _hasPremultipliedAlpha
protected
var _hasPremultipliedAlpha
protected
local _hasPremultipliedAlpha
protected
int _height
protected
var _height
protected
local _height
protected
MipmapInfo _mipmaps[MIPMAP_MAX]
protected
int _numberOfMipmaps
protected
var _numberOfMipmaps
protected
local _numberOfMipmaps
protected
bool _preMulti
protected
var _preMulti
protected
local _preMulti
protected
Texture2D::PixelFormat
_renderFormat
protected
var _renderFormat
protected
local _renderFormat
protected
int _width
protected
var _width
protected
local _width
protected
const int MIPMAP_MAX = 16
staticprotected

Determine how many mipmaps can we have.

Its same as define but it respects namespaces

var MIPMAP_MAX = 16
staticprotected

Determine how many mipmaps can we have.

Its same as define but it respects namespaces

local MIPMAP_MAX = 16
staticprotected

Determine how many mipmaps can we have.

Its same as define but it respects namespaces


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