Jump to content
  • Advertisement
Sign in to follow this  
Kreyden

Save scene in bmp?

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

Hi! I need know, how save the scene in a image bmp. In Delphi I hope you can help me to solve this problem... thanks

Share this post


Link to post
Share on other sites
Advertisement
I can't give you full code as I havn't written any delphi in years, but you wanna use the function glReadPixels to read out the framebuffer contents into a memory buffer. Then you use some imagelibrary to save it to a file/disk.

Share this post


Link to post
Share on other sites
Hi, thanks, I already solved there my problem I leave them the code.

Procedure CapturaEscena(Nombre:String);
var
Pixeles : array of Byte;
BMP : TBitmap;
X, Y,
I, L : Integer;
ViewPort:Array[1..4] of GLint;
Begin
glGetIntegerv(GL_VIEWPORT, @ViewPort);
Ancho:= viewport[3]*3;
SetLength(Pixeles, Ancho * ViewPort[3]);
glPixelStoref(GL_UNPACK_SWAP_BYTES, 1);
glReadPixels(0, 0, ViewPort[3], ViewPort[4], GL_RGB, GL_UNSIGNED_BYTE, Pixeles);
BMP:=TBitmap.Create;
BMP.pixelformat := pf32bit;
BMP.width := viewport[3];
BMP.height := viewport[4];
I := 0;
L := 0;
For Y := ViewPort[4] downto 1 do
Begin
L :=L+Ancho;
I :=L;
For X :=1 to ViewPort[3] do
Begin
BMP.Canvas.Pixels[X, Y] := RGB(Pixeles[I+1], Pixeles[I+2], Pixeles);
I := I+3;
End;
Inc(L);
End;
BMP.SaveToFile(Nombre);
BMP.Free;
End;

Espero le sirva ha alguien mas.

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!