// set loops for the whole animation
GlobalMetadata.AddMetaItemForSave(SMetaAnimationLoops, 3);
// delay for each frame in ms
GlobalMetadata.AddMetaItemForSave(SMetaFrameDelay, 300, ImageIndex);
var
simg: TSingleImage;
mimg: TMultiImage;
Res: pbyte;
Begin
|
opengl code
|
glpopmatrix();
OpenGLControl1.SwapBuffers;
if (i<=35) then begin
Res:=getmem(openglcontrol1.Height*openglcontrol1.Width*sizeof(byte)*3);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, openglcontrol1.Width, openglcontrol1.Height, GL_RGB, GL_UNSIGNED_BYTE, Res);
simg:= TSingleImage.Create ;
simg:=TSingleImage.CreateFromParams (openglcontrol1.Width,openglcontrol1.Height,ifr8G8b8) ;
CopyMemory(simg.Bits, @Res[0], simg.Size);
freemem(Res);
SwapChannels(simg.ImageDataPointer^, ChannelRed, Channelblue); // swap red and blue colours
flipimage(simg.ImageDataPointer^); // flip image because opengl starts at bottom left, other formats top left
if (i=0) then begin
mimg:= TMultiImage.Create;
mimg.Assign(simg) ;
end
else if i>0 then begin
mimg.AddImage(simg) ;
end;
simg.free;
if i=35 then begin
mimg.SaveMultiToFile('test.gif');
mimg.free;
end;
i:= i+1;
end;
end;
Res:=getmem(openglcontrol1.Height*openglcontrol1.Width*sizeof(byte)*3);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, openglcontrol1.Width, openglcontrol1.Height, GL_RGB, GL_UNSIGNED_BYTE, Res);
mimg:= Tsingleimage.Create ;
mimg:=tsingleimage.CreateFromParams (openglcontrol1.Width,openglcontrol1.Height,ifr8G8b8) ;
CopyMemory(mimg.Bits, @Res[0], mImg.Size);
SwapChannels(mimg.ImageDataPointer^, ChannelRed, Channelblue); // swap red and blue colours
flipimage(mimg.ImageDataPointer^); // flip image because opengl starts at bottom left, other formats top left
mimg.SaveToFile ('test.png');
mimg.free;
freemem(res);
procedure TForm1.OpenGLControl1Paint(Sender: TObject);
var
Res: pbyte;
size:longint;
error:boolean;
FImage: Tdynimagedataarray;
begin
if Sender=nil then ;
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, double(width) / height, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glpushmatrix();
glTranslatef(0.0, 0.0,-6.0);
// |
// |
// Here's code to build opengl picture
// |
// |
glpopmatrix();
OpenGLControl1.SwapBuffers;
Res:=getmem(openglcontrol1.Height*openglcontrol1.Width*sizeof(byte)*4);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, openglcontrol1.Width, openglcontrol1.Height, GL_RGBA, GL_UNSIGNED_BYTE, Res);
error:=LoadMultiImageFromMemory (Res,openglcontrol1.Height*openglcontrol1.Width*sizeof(byte)*4,fimage);
savemultiimagetofile('C:\test.gif',fimage);
freemem(Res);
freeimagesinarray(fimage);
end;
Page created in 0.012 seconds with 19 queries.