WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
SoftwareImage.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
12{
13public:
14 SoftwareImage() = default;
15
17 SoftwareImage(int width, int height);
18
20 SoftwareImage(const uint8_t* bgraData, int width, int height);
21
23 int width() const { return w_; }
24
26 int height() const { return h_; }
27
29 bool empty() const { return w_ == 0 || h_ == 0; }
30
32 uint8_t* data() { return pixels_.data(); }
33
35 const uint8_t* data() const { return pixels_.data(); }
36
38 SoftwareImage scaled(int newWidth, int newHeight) const;
39
41 SoftwareImage mirrored() const;
42
46 bool savePNG(const std::string& path) const;
47
49 bool savePNG(const std::wstring& path) const;
50
56 void composite(const SoftwareImage& src, int destX, int destY, int blendMode = 1);
57
59 void assign(const SoftwareImage& src);
60
63 static SoftwareImage loadFromMemory(const uint8_t* data, int size);
64
65private:
66 int w_ = 0;
67 int h_ = 0;
68 std::vector<uint8_t> pixels_; // BGRA format, 4 bytes per pixel
69};
CPU-side image buffer storing BGRA pixel data.
std::vector< uint8_t > pixels_
void composite(const SoftwareImage &src, int destX, int destY, int blendMode=1)
Composite a source image onto this image at the given position.
SoftwareImage mirrored() const
Return a vertically mirrored copy.
bool savePNG(const std::string &path) const
Save as PNG to the given file path.
SoftwareImage()=default
bool empty() const
True if the image has zero dimensions.
void assign(const SoftwareImage &src)
Replace contents entirely with a copy of src.
static SoftwareImage loadFromMemory(const uint8_t *data, int size)
Load a JPEG image from a memory buffer.
SoftwareImage scaled(int newWidth, int newHeight) const
Return a scaled copy using bilinear interpolation.
const uint8_t * data() const
Const pointer to the raw BGRA pixel buffer.
int height() const
Image height in pixels.
uint8_t * data()
Mutable pointer to the raw BGRA pixel buffer.
int width() const
Image width in pixels.