This issue also happens with the devel branch commit 8a9ece2
When Image saves image data with Image::saveImage(), the saved image is corrupted because of wrongly specified stride bytes.
It is because the Image class assumes the data being saved has 3 channels whereas Image loads an image as 4 channels RGBA.
// in al_Image.cpp
bool Image::saveImage(std::string fileName, unsigned char *pixs, int width,
int height, bool flipVertically) {
al_stbSetFlipVertically(flipVertically);
return al_stbWriteImage(fileName.c_str(), pixs, width, height);
}
...
// in al_stb_image.cpp
bool al_stbWriteImage(const char *fileName, const unsigned char *data,
int width, int height) {
return stbi_write_png(fileName, width, height, 3, data, width * 3) == 0;
}
Above are the actual functions called. I think saveImage and al_stbWriteImage need to have a parameter for the number of channels instead of hard-coded "3"s inside the function.
Thanks. I had assumed that this would be mostly used for RGB buffer captures, but I've now added an option to have an alpha channel ba439b995f984dbb5a4fede89492cb2643077312
This issue also happens with the
devel
branch commit 8a9ece2When
Image
saves image data withImage::saveImage()
, the saved image is corrupted because of wrongly specified stride bytes.It is because the
Image
class assumes the data being saved has 3 channels whereasImage
loads an image as 4 channels RGBA.Above are the actual functions called. I think
saveImage
andal_stbWriteImage
need to have a parameter for the number of channels instead of hard-coded "3"s inside the function.