Sign in to follow this  

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this