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"?
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?
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.