Thread View: comp.graphics.api.opengl
6 messages
6 total messages
Started by Prof
Thu, 06 Jan 2000 00:00
How to make a scrrenshot
Author: Prof
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
41 lines
1760 bytes
1760 bytes
Hi.
I'm trying to make a screenshot of the framebuffer content and write it to a
.tga file.
Something is going wrong, because the screenshot is distorted.
Here is what I'm doing:
- To read the framebuffer :
// w = viewport width
// h = viewport height
// buffer is of size 3*w*h
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
- To write the .tga file:
1. writing the 18 header bytes:
// header[0] = 0;
// ....
// header[2] = 2;
// ....
// header[12] = w&255;
// header[13] = w>>8;
// header[14] = h&255;
// header[15] = h>>8;
// header[16] = 24;
// header[17] = 0;
2. And then writing the framebuffer content in BGR format
// before we write we are converting the framebuffer content
for (i = 0; i < (w*h* 3); i += 3)
{
temp = buff[i];
buff[i] = buff[i + 2];
buff[i + 2] = temp;
}
Does anybody know what's wrong here, or can you point me to some samples,
information, etc.
Thanks.
-- Markus
Re: How to make a scrrenshot
Author: Uwe Kotyczka
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
6 lines
841 bytes
841 bytes
You might have a look at my demo http://ws56.tinst.uni-jena.de/opengl.html. Search for OnEditCopy, it copies the scene to clipboard (bitmap). Hope this helps.
Re: How to make a scrrenshot
Author: Paul Richards
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
22 lines
1609 bytes
1609 bytes
Prof wrote:
>
> Hi.
>
> I'm trying to make a screenshot of the framebuffer content and write it to a
> .tga file.
>
> Something is going wrong, because the screenshot is distorted.
If the bit for grabbing the buffer is OK and it's just the writing the
file that screws things up then try using PPM, it is a much simpler file
format. I've made up a C++ class that can handle the I/O for you and I
could email you that if you like. The class has support for you to just
tell it where the buffer is and it'll use that memory for its image. It
should work a treat in this case.
Just email me if you want the source to the class..
--
Paul Richards (Pauldoo) - http://www.pauldoo.co.uk
I've not run any Microsoft code for 40 days.
How about you?
Re: How to make a scrrenshot
Author: Charles E Hardwidge
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
29 lines
1892 bytes
1892 bytes
<Example>
Where Width&Height are pixels, and channels is; RGB=3 RGBA=4.
char* MyPicture = (char*)malloc(Width*Height*ChannelTotal);
FILE* pMyOut = fopen("test out.raw", "wb");
glReadPixels(0,0,Width,Height,GL_RGBA,GL_UNSIGNED_BYTE,MyPicture);
fwrite(MyPicture,(Width*Height*ChannelTotal),1,pMyOut2);
fclose(pMyOut);
delete MyPicture;
<Comment>
Don't forget to access the file as a binary ("wb"), like a klutz I forgot to
do this a while ago and spent rather a long time tracking down the reason.
Sheesh, like I only started programming yesterday. This may explain
distorted pictures (you were not to clear about what you meant by
"distorted").
--
***Anti - Spam Email Address***
ANY correspondence not of direct relevance to my posting, or any offer of
sale will be considered SPAM. Under UK law this breaches the Computer Misuse
Act, rendering the sender liable to a three year sentence and/or unlimited
fine. By sending me email, you agree the sending be covered by UK law.
news@eatmyshorts.fsnet.co.uk
Please replace eatmyshorts with hardwidge to reply.
Re: How to make a scrrenshot
Author: Prof
Date: Fri, 07 Jan 2000 00:00
Date: Fri, 07 Jan 2000 00:00
13 lines
1031 bytes
1031 bytes
Thanks guys. All your ideas were very helpful. Especially the hint with the binary mode. Changed from "w" to "wb" and it worked. -- Markus Charles E Hardwidge <news@eatmyshorts.fsnet.co.uk> wrote in message news:852pl0$a64$1@newsg1.svr.pol.co.uk... > <Example> [...] > >
Re: How to make a scrrenshot
Author: Charles E Hardwidge
Date: Fri, 07 Jan 2000 00:00
Date: Fri, 07 Jan 2000 00:00
12 lines
1331 bytes
1331 bytes
Thought that might be the case :) -- ***Anti - Spam Email Address*** ANY correspondence not of direct relevance to my posting, or any offer of sale will be considered SPAM. Under UK law this breaches the Computer Misuse Act, rendering the sender liable to a three year sentence and/or unlimited fine. By sending me email, you agree the sending be covered by UK law. news@eatmyshorts.fsnet.co.uk Please replace eatmyshorts with hardwidge to reply.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads