Jump to content
  • Advertisement
Sign in to follow this  
Mamadcloud

Image Compression

This topic is 3621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dear all, I need help for developing image compression program. Do anyone know any sample source code for it (compressing bitmap to jpeg or anything else)? Sorry if it is not right topic, but I really really need help.. Thank you very much guyz... Regards, Mcloud

Share this post


Link to post
Share on other sites
Advertisement
What formats do you need to compress to? JPEG and PNG both have reference implementations you can use, libjpeg and libpng. However they're not exactly the easiest to use. You may want to use a library that has many different encoders available, like GDI+.

Share this post


Link to post
Share on other sites




A source code for jpeg decoder is available here
http://www.users.voicenet.com/~richgel/

This jpeg decoder is developed according to formal standards laid out by international standards.

I can answer any further clarifications in jpeg decoder.









Share this post


Link to post
Share on other sites
I want to compress BITMAP(24-bit), I loaded the image using DIB (if Im right) and retrieve the image info. I want to get the RGB value for each pixel. but I dunno how to get it, and I want to convert RGB to YUV. anybody know?

Thank you for your reference, rajesh_nest, I'll try to read the code.
lots of thank, guyz...

Share this post


Link to post
Share on other sites
Simplest thing would be to take an image library such as DevIL, Corona or FreeImage. These libraries can load and save images in various formats and it's easy to get access to the pixels.

To access pixels in a windows HBITMAP, you need to use GetDIBits() which requires that the bitmap is actually a DIB section. Only worth the trouble if you actually need to have the image data as a HBITMAP for use on dialogs or printing.

As an example, using Corona, it would work like this:


corona::Image *myImage = corona::OpenImage(
"Input.bmp", corona::PF_R8G8B8A8
);

void *pixels = myImage->getPixels();

for(int y = 0; y < myImage->getHeight(); ++y) {
for(int x = 0; x < myImage->getWidth(); ++x) {
int pixelOffset = (myImage->getWidth() * y + x) * 4;
char *pixelAddress = reinterpret_cast<char *>(pixels) + pixelOffset;

// convert RGBA pixel at pixelAddress to YUV here
}
}

corona::SaveImage("Output.jpg", corona::FF_JPEG, myImage);

delete myImage;



I think some of the other image libraries might even be able to convert to YUV themselves, but I haven't used them in a long time ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!