Jump to content
  • Advertisement
Sign in to follow this  

Should I Just Write My Own Screenshot Code? (FreeImage vs DIY)

This topic is 2708 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

Okay I'm working on a vector image editor and I created a export application and all it is, is pretty much a GLUT app that reads the pixels off the OpenGL window real fast and uses FreeImage to save the frame as a file type. This works and all, but I'm getting ugly results... XP And yes I looked at the frame before my GLUT app closes to see what the frame works like in the GLUT window.

I'll attach some example images FreeImage makes when I tell it to save raw pixels, as you can tell I get different results on different file types on the same thing and I appear to loss lots of detail when I export a frame from OpenGL -> FreeImage -> File Type on system. (You have to zoom into the image to see the image better)

Should I just create my own export script for supported file types or should I just do some changes in my FreeImage export script?

Here is some code:


if(m_ImageType != IMAGE_TRANSPARENT)

imageData = (BYTE *)malloc(RenderImageWidth*RenderImageHeight*3); //Allocate memory for storing the image
glReadPixels(0, 0, RenderImageWidth, RenderImageHeight, GL_BGR, GL_UNSIGNED_BYTE, imageData); //Cop
imageData = (BYTE *)malloc(RenderImageWidth*RenderImageHeight*4); //Allocate memory for storing the image

glReadPixels(0, 0, RenderImageWidth, RenderImageHeight, GL_BGRA, GL_UNSIGNED_BYTE, imageData); //Cop


if(m_ImageType != IMAGE_TRANSPARENT)
Image = FreeImage_ConvertFromRawBits(imageData, RenderImageWidth, RenderImageHeight, 3*RenderImageWidth, 24, 0xFF0000, 0x00FF00, 0x0000FF, false);
Image = FreeImage_ConvertFromRawBits(imageData, RenderImageWidth, RenderImageHeight, 4*RenderImageWidth, 32, 0xFF0000, 0x00FF00, 0x0000FF, false);
FreeImage_Save( formato, Image, ImageSavePath.c_str(), 0);

As you can tell most of the variable names are self explanatory such as m_ImageType is a enum to determin if an image is using a alpha channel for the background and RenderImageWidth & RenderImageHeight are the image's size I want to export.

Any help would be appreciated, I'm using my project to help my girl friend to start her own business and I want to put my program to the test creating business cards, but if I'm asking too much from what these image file types can do, please say so.

Thanks, Andrew.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!