I am trying to read TGA file and then need to compress to almost half the size of the image file. How can this be achieved in cpp?
Any suggestions using graphics apis like opengl/directx.
Below is what I have tried so far in opengl.
as far as I know tga only supports RLE which is not going to ensure 50% compression.
you would have to preprocess the file to get that... probably cut it in half (# of bytes, not dimensions!) first... eg a 100x200 (20k bytes in greyscale) can be 70x140 (9800 bytes greyscale). A little math will get you the exact dimensions, but its not going to be 50x100. RLE can make things bigger, if each entry is unique, eg random pixels. That mean you have to decide if you need exactly 50% or 'thereabouts'. if you need it exact, you do need to round down the dimension resize. If close is ok, round up and hope the RLE makes it smaller instead of larger, and consider random images (bad entropy) to be an anomaly (most real images will not be like that).
Depends on the image, of course. Simple icons might compress well.
Of course, we really haven't much idea what the guy really wants.
Does he want to store the compressed images in a different format?
By "compressed" does he perhaps mean "downsampled"?
Who knows.
By "compressed" here means scale down to half the size, by creating copy of the actual image . This is to be done for the TGA. any compression techniques would help here or do I need to convert this TGA file to some other format?
Do you know if any sort of algorithm can help to achieve copy of actual image to scale down to half the size of actual TGA( must be uncompressed), and must support RGB, RGBA?
to cut the actual physical dimensions in half, that is on the web, there are several resamples eg bicubic and so on that do it with minimal damage.
to cut the byte size in half, the best is a wavelet, j2k, jpg, and some unpopular R&D wavelets cut the size by dramatic amounts of course but its not supported to compress TGA this way.
What is the current dimensions and bit depth?
Are they currently RLE compressed?
Are they mostly solid colors? Like icons? Or are they like photographs?
Can you upload a few of them somewhere?
Are your pictures photographic or iconic (where iconic means mostly solid colors, like a cartoon)?
Try running the following hex dump of the first 128 bytes on one of your files and post the results:
you can't post a file here, you can post it to another site and link, or maybe uuencode it (please don't lol) if absolutely necessary.
you can open it in your hex editor, visual studio has one built in, or grab a free one off the web.
you can also write something ... file.read(mycharptr, sizeoffile) ... for(.. size of file..) write it in hex <<hex<< for cout or %x for printf.