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

A class for paring Android .9 patch image. More...

#include <NinePatchImageParser.h>

Public Member Functions

 NinePatchImageParser ()
 Default constructor.
 
 NinePatchImageParser (Image *image)
 Instantiate a NinePatchImageParser with a Image object.
 
 NinePatchImageParser (Image *image, const Rect &frameRect, bool rotated)
 Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.
 
void setSpriteFrameInfo (Image *image, const Rect &frameRect, bool rotated)
 Change the sprite frame info.
 
virtual ~NinePatchImageParser ()
 Default destructor.
 
Rect parseCapInset () const
 Parsing the image data and extract the capInsets info.
 

Static Public Member Functions

static bool isNinePatchImage (std::string_view filename)
 Determines whether a filename contains ".9.png" suffix.
 

Detailed Description

A class for paring Android .9 patch image.

For more about Android .9 patch image format, please refer to http://developer.android.com/tools/help/draw9patch.html

The class could parse a single .9 patch image and produce the capInsets as well as a sprite atlas and store all the capInsets infos in a Texture2D. Note:

  • Currently only PixelFormat::RGBA8 is supported.
  • TexturePacker Trim mode is not supported at the moment.

Constructor & Destructor Documentation

◆ NinePatchImageParser() [1/2]

NinePatchImageParser ( Image * image)
explicit

Instantiate a NinePatchImageParser with a Image object.

Parameters
imageA Image object pointer.
Returns
A NinePatchImageParser instance.

◆ NinePatchImageParser() [2/2]

NinePatchImageParser ( Image * image,
const Rect & frameRect,
bool rotated )

Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.

The spriteFrame contains the frame rect in the image atlas and whether it is rotated or not.

Parameters
imageA Image object pointer.
frameRectThe sprite frame rect in the image atlas.
rotatedWhether is sprite frame is rotated in the image atlas.

Member Function Documentation

◆ isNinePatchImage()

static bool isNinePatchImage ( std::string_view filename)
static

Determines whether a filename contains ".9.png" suffix.

Parameters
filenameA 9-patch image name.
Returns
If the filename contains ".9.png", then return true, otherwise false.

◆ setSpriteFrameInfo()

void setSpriteFrameInfo ( Image * image,
const Rect & frameRect,
bool rotated )

Change the sprite frame info.

It is useful when parsing multiple sprite frame with only on NinePatchImageParser.

Parameters
frameRectThe sprite frame rect in the image atlas.
rotatedWhether is sprite frame is rotated in the image atlas.

◆ parseCapInset()

Rect parseCapInset ( ) const

Parsing the image data and extract the capInsets info.

Returns
The capInsets Rect.

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