sptk2 logo
SPTK Home Page
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
sptk::CPngImage Class Reference

PNG image that is initialized from the memory buffer. More...

#include <CPngImage.h>

Inheritance diagram for sptk::CPngImage:
sptk::CFrame

Public Types

enum class  CPatternDrawMode : uint8_t { PDM_UNDEFINED , PDM_TILE , PDM_STRETCH }
 The way how the resized parts of image are drawn. More...
 

Public Member Functions

void cutTileDraw (int srcX, int srcY, int srcW, int srcH, int destX, int destY, int destW, int destH)
 Draws a part of the image by cutting a corresponding source and tiling it in required area. More...
 
void cutStretchDraw (int srcX, int srcY, int srcW, int srcH, int destX, int destY, int destW, int destH)
 Draws a part of the image by cutting a corresponding source and stretching it in required area. More...
 
 CPngImage (const Buffer &imagedata)
 Constructor. More...
 
 CPngImage (const Fl_RGB_Image *image)
 Constructor. More...
 
 CPngImage (const String &fileName)
 Constructor. More...
 
void drawResized (int x, int y, int w, int h, int cornerZone, CPatternDrawMode drawMode, bool drawBackground)
 Draws resized image. More...
 
void drawResized (int x, int y, int w, int h, int border[], CPatternDrawMode drawMode, bool drawBackground)
 Draws resized image. More...
 

Protected Member Functions

void load (const Buffer &buffer)
 Internal loader from PNG image buffer. More...
 

Static Protected Member Functions

static void cutTileDraw (CPngImage *image, int srcX, int srcY, int srcW, int srcH, int destX, int destY, int destW, int destH)
 Draws a part of the image by cutting a corresponding source and tiling it in required area. More...
 
static void cutStretchDraw (CPngImage *image, int srcX, int srcY, int srcW, int srcH, int destX, int destY, int destW, int destH)
 Draws a part of the image by cutting a corresponding source and stretching it in required area. More...
 

Friends

class CIcon
 

Detailed Description

PNG image that is initialized from the memory buffer.

This class is used by SPTK themes

Member Enumeration Documentation

◆ CPatternDrawMode

enum class sptk::CPngImage::CPatternDrawMode : uint8_t
strong

The way how the resized parts of image are drawn.

By resized parts I mean everything besides four corners. Corners are rectangles with the side of corner zone

Enumerator
PDM_UNDEFINED 

Undefined and not drawn, should be defined later.

PDM_TILE 

The resized parts are tiled

PDM_STRETCH 

The resized parts are stretched

Constructor & Destructor Documentation

◆ CPngImage() [1/3]

sptk::CPngImage::CPngImage ( const Buffer imagedata)
explicit

Constructor.

An object of the class contains it's own copy of the image data

Parameters
imagedataconst CBuffer&, PNG image data in memory buffer

◆ CPngImage() [2/3]

sptk::CPngImage::CPngImage ( const Fl_RGB_Image *  image)
explicit

Constructor.

An object of the class contains it's own copy of the image data

Parameters
imageFl_RGB_Image*, RGB image data in memory buffer

◆ CPngImage() [3/3]

sptk::CPngImage::CPngImage ( const String fileName)
explicit

Constructor.

An object of the class contains it's own copy of the image data

Parameters
fileNamestd::string, image file (.png)

Member Function Documentation

◆ cutStretchDraw() [1/2]

static void sptk::CPngImage::cutStretchDraw ( CPngImage image,
int  srcX,
int  srcY,
int  srcW,
int  srcH,
int  destX,
int  destY,
int  destW,
int  destH 
)
staticprotected

Draws a part of the image by cutting a corresponding source and stretching it in required area.

Parameters
imageCPngImage*, source image
srcXint, x-coordinate of the source fragment
srcYint, y-coordinate of the source fragment
srcWint, width of the source fragment
srcHint, height of the source fragment
destXint, x-coordinate of the destination fragment
destYint, y-coordinate of the destination fragment
destWint, width of the destination fragment
destHint, height of the destination fragment

◆ cutStretchDraw() [2/2]

void sptk::CPngImage::cutStretchDraw ( int  srcX,
int  srcY,
int  srcW,
int  srcH,
int  destX,
int  destY,
int  destW,
int  destH 
)
inline

Draws a part of the image by cutting a corresponding source and stretching it in required area.

Parameters
srcXint, x-coordinate of the source fragment
srcYint, y-coordinate of the source fragment
srcWint, width of the source fragment
srcHint, height of the source fragment
destXint, x-coordinate of the destination fragment
destYint, y-coordinate of the destination fragment
destWint, width of the destination fragment
destHint, height of the destination fragment

◆ cutTileDraw() [1/2]

static void sptk::CPngImage::cutTileDraw ( CPngImage image,
int  srcX,
int  srcY,
int  srcW,
int  srcH,
int  destX,
int  destY,
int  destW,
int  destH 
)
staticprotected

Draws a part of the image by cutting a corresponding source and tiling it in required area.

Parameters
imageCPngImage*, source image
srcXint, x-coordinate of the source fragment
srcYint, y-coordinate of the source fragment
srcWint, width of the source fragment
srcHint, height of the source fragment
destXint, x-coordinate of the destination fragment
destYint, y-coordinate of the destination fragment
destWint, width of the destination fragment
destHint, height of the destination fragment

◆ cutTileDraw() [2/2]

void sptk::CPngImage::cutTileDraw ( int  srcX,
int  srcY,
int  srcW,
int  srcH,
int  destX,
int  destY,
int  destW,
int  destH 
)
inline

Draws a part of the image by cutting a corresponding source and tiling it in required area.

Parameters
srcXint, x-coordinate of the source fragment
srcYint, y-coordinate of the source fragment
srcWint, width of the source fragment
srcHint, height of the source fragment
destXint, x-coordinate of the destination fragment
destYint, y-coordinate of the destination fragment
destWint, width of the destination fragment
destHint, height of the destination fragment

◆ drawResized() [1/2]

void sptk::CPngImage::drawResized ( int  x,
int  y,
int  w,
int  h,
int  border[],
CPatternDrawMode  drawMode,
bool  drawBackground 
)

Draws resized image.

Parameters
xint, the x coordinate to draw image
yint, the y coordinate to draw image
wint, the width to draw image
hint, the height to draw image
borderint[], the borders that are copied from the image with minimal possible processing
drawModeCPatternDrawMode, the mode to draw the resized parts of image
drawBackgroundbool, if true then the internal area of the image is used for background

◆ drawResized() [2/2]

void sptk::CPngImage::drawResized ( int  x,
int  y,
int  w,
int  h,
int  cornerZone,
CPatternDrawMode  drawMode,
bool  drawBackground 
)

Draws resized image.

Parameters
xint, the x coordinate to draw image
yint, the y coordinate to draw image
wint, the width to draw image
hint, the height to draw image
cornerZoneint, the height (and width) of the corners that are simply copied from the image w/o processing
drawModeCPatternDrawMode, the mode to draw the resized parts of image
drawBackgroundbool, if true then the internal area of the image is used for background

Referenced by sptk::CFrame::drawResized().

◆ load()

void sptk::CPngImage::load ( const Buffer buffer)
protected

Internal loader from PNG image buffer.

Parameters
bufferconst CBuffer&, image data

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

Fri Oct 14 2022 09:58:39: SPTK 5.4.1