Post reply

Name
Email
Subject
Message icon                                  
Attach:
(Clear Attachment)
(more attachments)
Restrictions: 6 per post, maximum total size 4096KB, maximum individual size 2048KB
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Enter or copy Vampyre Imaging Library as an verification (we ge a lot of registration spam):

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Galfar
« on: 27 October 2013, 01:38:10 »

Support for frame delays and animation loop count was added finally.
Posted by: Galfar
« on: 30 October 2010, 01:00:10 »

I uploaded a fix for infinite delays. Please test it.
AddMetaItemForSave for PNG only works for print resolution metadatas, not animations yet.
Hopefully I'll get to it ina few days.
Posted by: mkoijn
« on: 28 October 2010, 17:10:57 »

Thanks for that. I'm having trouble getting that to work. The gifs animate once only no matter what integer I set in
GlobalMetadata.AddMetaItemForSave(SMetaAnimationLoops, 0 ); It should be that if it's set to zero it should animate indefinately?
Also do the GlobalMetadata.AddMetaItemForSave features work for both gif and png?

Thanks again.
Posted by: Galfar
« on: 27 October 2010, 23:19:33 »

I'v updated SVN reposiotory with these new GIF saving features.
Set metadata before saving the GIF like this:

Code: [Select]
// set loops for the whole animation
GlobalMetadata.AddMetaItemForSave(SMetaAnimationLoops, 3);

// delay for each frame in ms
GlobalMetadata.AddMetaItemForSave(SMetaFrameDelay, 300, ImageIndex);
Posted by: mkoijn
« on: 26 October 2010, 10:38:58 »

That's great. Would it also be possible to have an option for the gif to loop continuosly?

Many thanks again for a great library.
Posted by: Galfar
« on: 26 October 2010, 02:31:38 »

This can be done with new metadata support in the latest versions in SVN
but I haven't uploaded GIF support yet (only APNG stores delays now).
I'll test it and upload it in a few days.
Posted by: mkoijn
« on: 25 October 2010, 19:18:36 »

Ah, silly mistake, I forgot to declare Mimg outside the procedure. It works now.

Is there anyway to regulate the delay between frames in the saved gif?

Thanks a lot.
Posted by: mkoijn
« on: 25 October 2010, 17:57:03 »

Hi,

I've been trying to convert the code to save the first 36 frames of an opengl window over the last couple of hours using TMultiImage, following examples in "high level interface" in the documentation. Has AddLevel been superceded by AddImage?
However I keep getting a SIGSEGV exception whenever I have the lines:    mimg.AddImage(simg) ;    mimg.SaveMultiToFile('test.gif');   or
mimg.free;   If I comment out all these lines it compiles and runs, but of course it doesn't save an image to disc. Here's what I have so far:

integer i is declared and initialised to 0 before the procedure is called.

Thanks for any help.

Code: [Select]
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;                             
Posted by: Galfar
« on: 25 October 2010, 14:48:38 »

To create GIF with multiple images inside just use TMultiImage instead of TSingleImage in your code.
Just note that GIF can store only 256 colors for one image, so your screenshots
may look quite ugly when saved to GIF. Other multi image formats supported by Imaging that also support 24/32bit colors are MNG and APNG.
Posted by: mkoijn
« on: 25 October 2010, 14:04:44 »

Thanks for that, much appreciated.
Just for reference, here's the code to save a screenshot from an opengl canvas.

Code: [Select]
   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);         
Posted by: Galfar
« on: 24 October 2010, 20:37:11 »

Hi,
if you have pixels already in memory there's no need to use LoadImageFromMemory - that's for loading images stored
in one of supported file formats (JPG, PNG, etc.).
Just copy part of memory with pixels, see this thread http://galfar.vevb.net/imaging/smf/index.php/topic,281.0.html

Posted by: mkoijn
« on: 24 October 2010, 16:51:27 »

Hi, I'm trying to use Vampyr to save a screenshot of an opengl window. I'm using Lazarus 0.9.28.2 on windows xp.

I'm using glreadpixels to get the rgba values from the opengl canvas and storing the values in a pointer. Then trying to load the data using LoadMultiImageFromMemory , however it returns an error. Here's my code so far. Any help would be great.

Eventually I would like to save animated gifs from the opengl window, is this possible with the Vampyr Imaging Library? and thanks for making the library available.

Code: [Select]
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;