Original Post
🔒 Locked
Saving BMP from the framebuffer
Advertisement
just call saveBitmapFromFramebuffer()
works for me
oh yeah, you might also need to learn about the BMP file format and how to read data from the framebuffer so that saveBitmapFromFramebuffer() works properly...
live and learn...it''s quite simple really
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Kierkegaard reminds us that belief
has nothing to do with how or why.
Belief is beyond reason.
I believe because it is absurd."
works for me
oh yeah, you might also need to learn about the BMP file format and how to read data from the framebuffer so that saveBitmapFromFramebuffer() works properly...
live and learn...it''s quite simple really
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Kierkegaard reminds us that belief
has nothing to do with how or why.
Belief is beyond reason.
I believe because it is absurd."
void GetScreenShot(char *Filename)
{
FILE *Out;
unsigned char *Buff;
// Capture a screen shot. Save as a RAW-format file.
// First, allocate memory.
Buff = new unsigned char[ScreenWidth*ScreenHeight*3];
// Now, get pixels.
glReadBuffer(GL_FRONT);
glReadPixels(0,0, ScreenWidth, ScreenHeight, GL_RGB, GL_UNSIGNED_BYTE, Buff);
// Now, open to file and write pixels.
Out = fopen(Filename, "wb");
if(!Out) return;
fwrite(Buff, 3, ScreenWidth*ScreenHeight, Out);
fclose(Out);
delete[] Buff;
}
This is a quick function that will grab a screenshot and save it to a .RAW format (without any header data). You would have to modify it to save to .BMP (I never use .BMP, so I don't know the format), but this should be fairly simple if you read up on the file format here. The important part is the glReadPixels(), call which basically grabs RGB pixels from the front buffer into your own buffer. You can do basically whatever you want with it after that.
Of course, Windows may have it's own little functions for doing this; I wouldn't know, as I choose not to use Windows.
Josh
vertexnormal AT linuxmail DOT org
Check out Golem at:
My cheapass website
[edited by - VertexNormal on September 10, 2003 2:13:23 PM]
{
FILE *Out;
unsigned char *Buff;
// Capture a screen shot. Save as a RAW-format file.
// First, allocate memory.
Buff = new unsigned char[ScreenWidth*ScreenHeight*3];
// Now, get pixels.
glReadBuffer(GL_FRONT);
glReadPixels(0,0, ScreenWidth, ScreenHeight, GL_RGB, GL_UNSIGNED_BYTE, Buff);
// Now, open to file and write pixels.
Out = fopen(Filename, "wb");
if(!Out) return;
fwrite(Buff, 3, ScreenWidth*ScreenHeight, Out);
fclose(Out);
delete[] Buff;
}
This is a quick function that will grab a screenshot and save it to a .RAW format (without any header data). You would have to modify it to save to .BMP (I never use .BMP, so I don't know the format), but this should be fairly simple if you read up on the file format here. The important part is the glReadPixels(), call which basically grabs RGB pixels from the front buffer into your own buffer. You can do basically whatever you want with it after that.
Of course, Windows may have it's own little functions for doing this; I wouldn't know, as I choose not to use Windows.
Josh
vertexnormal AT linuxmail DOT org
Check out Golem at:
My cheapass website
[edited by - VertexNormal on September 10, 2003 2:13:23 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement