Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
Image Class Reference

The Image class for loading all images supported by axmol . More...

#include <Image.h>

Inherits Object.

Public Types

enum class  Format {
  JPG , PNG , BMP , WEBP ,
  PVR , ETC1 , ETC2 , S3TC ,
  ATITC , TGA , ASTC , RAW_DATA ,
  UNKNOWN
}
 Supported formats for Image. More...
 

Public Member Functions

 Image ()
 @js ctor
 
virtual ~Image ()
 @js NA @lua NA
 
bool initWithImageFile (std::string_view path)
 Load the image from the specified path.
 
bool initWithImageData (const uint8_t *data, ssize_t dataLen)
 Load image from stream buffer.
 
bool saveToFile (std::string_view filename, bool isToRGB=true)
 Save Image data to the specified file, with specified format.
 
- Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
 
void release ()
 Releases the ownership immediately.
 
Objectautorelease ()
 Releases the ownership sometime soon automatically.
 
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
 
virtual ~Object ()
 Destructor.
 

Static Public Member Functions

static void setPNGPremultipliedAlphaEnabled (bool enabled)
 Enables or disables premultiplied alpha for PNG files.
 
static void setCompressedImagesHavePMA (uint32_t targets, bool havePMA)
 The new APIs to treats (or not) compressed image files as if they have alpha premultiplied.
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 

Detailed Description

The Image class for loading all images supported by axmol .

Member Enumeration Documentation

◆ Format

enum class Format
strong

Supported formats for Image.

Enumerator
JPG 

JPEG.

PNG 

PNG.

BMP 

BMP,.

WEBP 

WebP.

PVR 

PVR.

ETC1 

ETC1.

ETC2 

ETC2.

S3TC 

S3TC.

ATITC 

ATITC.

TGA 

TGA.

ASTC 

ASTC.

RAW_DATA 

Raw Data.

UNKNOWN 

Unknown format.

Member Function Documentation

◆ setPNGPremultipliedAlphaEnabled()

static void setPNGPremultipliedAlphaEnabled ( bool enabled)
inlinestatic

Enables or disables premultiplied alpha for PNG files.

Parameters
enabled(default: true)

◆ setCompressedImagesHavePMA()

static void setCompressedImagesHavePMA ( uint32_t targets,
bool havePMA )
static

The new APIs to treats (or not) compressed image files as if they have alpha premultiplied.

By default, ETC1 + ETC1_ALPHA is enabled, because we do PMA at shader etc1.frag !!!IMPORTANT: The spine-runtimes official always regard texture has PMA, so you needs do compressed images PMA at texture convert tools or GPU fragment shader, such as positionTexture.frag, positionTextureColor.frag and others which have texture sampler, otherwise, the spine animations can't be render properly

◆ initWithImageFile()

bool initWithImageFile ( std::string_view path)

Load the image from the specified path.

Parameters
paththe absolute file path.
Returns
true if loaded correctly.

◆ initWithImageData()

bool initWithImageData ( const uint8_t * data,
ssize_t dataLen )

Load image from stream buffer.

Parameters
datastream buffer which holds the image data.
dataLendata length expressed in (number of) bytes.
ownDatawhether take the data memory management.
Returns
true if loaded correctly. @js NA @lua NA

◆ saveToFile()

bool saveToFile ( std::string_view 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.

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