-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathpng_toolkit.cpp
More file actions
34 lines (28 loc) · 767 Bytes
/
png_toolkit.cpp
File metadata and controls
34 lines (28 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <array>
#include "stb_image_write.h"
#include "png_toolkit.h"
png_toolkit::png_toolkit()
{
}
png_toolkit::~png_toolkit()
{
stbi_image_free(imgData.pixels);
}
bool png_toolkit::load( const std::string &pictureName )
{
imgData.pixels = stbi_load(pictureName.c_str(), &imgData.w, &imgData.h, &imgData.compPerPixel, 0);
return imgData.pixels != nullptr;
}
bool png_toolkit::save( const std::string &pictureName )
{
return stbi_write_png(pictureName.c_str(),
imgData.w, imgData.h,
imgData.compPerPixel,
imgData.pixels, 0) != 0;
}
image_data png_toolkit::getPixelData( void ) const
{
return imgData;
}