WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
SoftwareImage Class Reference

CPU-side image buffer storing BGRA pixel data. More...

#include <SoftwareImage.h>

Public Member Functions

 SoftwareImage ()=default
 
 SoftwareImage (int width, int height)
 Create a blank image with the given dimensions.
 
 SoftwareImage (const uint8_t *bgraData, int width, int height)
 Construct from existing BGRA pixel data (copies the data).
 
int width () const
 Image width in pixels.
 
int height () const
 Image height in pixels.
 
bool empty () const
 True if the image has zero dimensions.
 
uint8_t * data ()
 Mutable pointer to the raw BGRA pixel buffer.
 
const uint8_t * data () const
 Const pointer to the raw BGRA pixel buffer.
 
SoftwareImage scaled (int newWidth, int newHeight) const
 Return a scaled copy using bilinear interpolation.
 
SoftwareImage mirrored () const
 Return a vertically mirrored copy.
 
bool savePNG (const std::string &path) const
 Save as PNG to the given file path.
 
bool savePNG (const std::wstring &path) const
 Save as PNG to the given wide-string file path.
 
void composite (const SoftwareImage &src, int destX, int destY, int blendMode=1)
 Composite a source image onto this image at the given position.
 
void assign (const SoftwareImage &src)
 Replace contents entirely with a copy of src.
 

Static Public Member Functions

static SoftwareImage loadFromMemory (const uint8_t *data, int size)
 Load a JPEG image from a memory buffer.
 

Private Attributes

int w_ = 0
 
int h_ = 0
 
std::vector< uint8_t > pixels_
 

Detailed Description

CPU-side image buffer storing BGRA pixel data.

Provides scaling, mirroring, compositing, and PNG save operations. Replaces QImage/QPainter for texture composition in the WoW Model Viewer.

Definition at line 11 of file SoftwareImage.h.

Constructor & Destructor Documentation

◆ SoftwareImage() [1/3]

SoftwareImage::SoftwareImage ( )
default

◆ SoftwareImage() [2/3]

SoftwareImage::SoftwareImage ( int  width,
int  height 
)

Create a blank image with the given dimensions.

Definition at line 12 of file SoftwareImage.cpp.

◆ SoftwareImage() [3/3]

SoftwareImage::SoftwareImage ( const uint8_t *  bgraData,
int  width,
int  height 
)

Construct from existing BGRA pixel data (copies the data).

Definition at line 17 of file SoftwareImage.cpp.

Member Function Documentation

◆ assign()

void SoftwareImage::assign ( const SoftwareImage src)

Replace contents entirely with a copy of src.

Definition at line 206 of file SoftwareImage.cpp.

Here is the caller graph for this function:

◆ composite()

void SoftwareImage::composite ( const SoftwareImage src,
int  destX,
int  destY,
int  blendMode = 1 
)

Composite a source image onto this image at the given position.

Parameters
srcSource image to composite.
destXHorizontal offset in this image.
destYVertical offset in this image.
blendMode1 = SourceOver (default), 4 = Multiply, 6 = Overlay.

Definition at line 143 of file SoftwareImage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [1/2]

uint8_t * SoftwareImage::data ( )
inline

Mutable pointer to the raw BGRA pixel buffer.

Definition at line 32 of file SoftwareImage.h.

Here is the caller graph for this function:

◆ data() [2/2]

const uint8_t * SoftwareImage::data ( ) const
inline

Const pointer to the raw BGRA pixel buffer.

Definition at line 35 of file SoftwareImage.h.

◆ empty()

bool SoftwareImage::empty ( ) const
inline

True if the image has zero dimensions.

Definition at line 29 of file SoftwareImage.h.

Here is the caller graph for this function:

◆ height()

int SoftwareImage::height ( ) const
inline

Image height in pixels.

Definition at line 26 of file SoftwareImage.h.

Here is the caller graph for this function:

◆ loadFromMemory()

SoftwareImage SoftwareImage::loadFromMemory ( const uint8_t *  data,
int  size 
)
static

Load a JPEG image from a memory buffer.

Returns
A BGRA SoftwareImage (empty on failure).

Definition at line 213 of file SoftwareImage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mirrored()

SoftwareImage SoftwareImage::mirrored ( ) const

Return a vertically mirrored copy.

Definition at line 67 of file SoftwareImage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ savePNG() [1/2]

bool SoftwareImage::savePNG ( const std::string &  path) const

Save as PNG to the given file path.

Internally converts BGRA → RGBA for stb_image_write.

Definition at line 92 of file SoftwareImage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ savePNG() [2/2]

bool SoftwareImage::savePNG ( const std::wstring &  path) const

Save as PNG to the given wide-string file path.

Definition at line 104 of file SoftwareImage.cpp.

Here is the call graph for this function:

◆ scaled()

SoftwareImage SoftwareImage::scaled ( int  newWidth,
int  newHeight 
) const

Return a scaled copy using bilinear interpolation.

Definition at line 22 of file SoftwareImage.cpp.

Here is the call graph for this function:

◆ width()

int SoftwareImage::width ( ) const
inline

Image width in pixels.

Definition at line 23 of file SoftwareImage.h.

Here is the caller graph for this function:

Member Data Documentation

◆ h_

int SoftwareImage::h_ = 0
private

Definition at line 67 of file SoftwareImage.h.

◆ pixels_

std::vector<uint8_t> SoftwareImage::pixels_
private

Definition at line 68 of file SoftwareImage.h.

◆ w_

int SoftwareImage::w_ = 0
private

Definition at line 66 of file SoftwareImage.h.


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