I am having a problem with file sizes when loading a PNG image, serializing it into a file, and then reloading the saved file and serializing it again. I have read another post about JPG compression sizes and this could be the same thing, but I am explaining my problem just in case I am talking about different things.
The code is shown below:
const Image img = ImageFileFormat::loadFrom("aa.png"); File file = File("image.dat"); ScopedPointer <FileOutputStream> destStream = file.createOutputStream(); PNGImageFormat pngimage; pngimage.writeImageToStream(img, *destStream);
After this, the size of image.dat is 5067 bytes.
Then I load the image and save it again:
FileInputStream inputStream(file); //"image.dat" const Image img2 = ImageFileFormat::loadFrom(*inputStream); ScopedPointer <FileOutputStream> destStream2 = file.createOutputStream(); PNGImageFormat pngimage2; pngimage2.writeImageToStream(img2, destStream2);
After this, the size of image.dat is 5070 bytes.
If you do this repeteadly, file size keeps getting bigger. I have to admit every image loads and saves correctly.
What is happening?. Is it the same reason of the other post about JPG compression algorithm?
Thanks to all,