Sign in to follow this  
Kreyden

Save scene in bmp?

Recommended Posts

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 := 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

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