0

I am using FreeImagePlus/FreeImage. I want to compress the bitmaps without saving them to HDD (files) using FreeImagePlus/FreeImage.

The given function FreeImage_save does compress but its main aim is to save that image into a file in hard drive.

I am interested in compression only. How can I do this?

tod
  • 1,539
  • 4
  • 17
  • 43
  • Why negative vote, any justification? – tod Dec 27 '16 at 15:44
  • Google: [this page](http://freeimage.sourceforge.net/fip/classfipMemoryIO.html) talks about image I/O with memory streams, for example `save (FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags=0)` *Saves a dib to a memory stream.* – Weather Vane Dec 27 '16 at 15:55

1 Answers1

0

The saveToMemory function does the job. Compress only can be implemented by using compress and save to memory, as following:

fipImage img;
img.load("file.jpg");       
if (!img.isValid()) 
    cout <<"could not read the input image" << endl;

//For compress only: save image to memory

fipMemoryIO memIO;

if(!img.saveToMemory(CompressionFormat[j], memIO, 0)); 
cout<< "could not compress image" << endl;

Now memIO contains the saved image in the given compression format.

In other words, raw image from memory is compressed and the output (compressed image) is put back to memory.

tod
  • 1,539
  • 4
  • 17
  • 43