Exporting images from ZGE

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Exporting images from ZGE

Post by Ats » Tue Dec 09, 2014 4:36 pm

Hi,

I'd like to make some animated gif from rotating models in ZGE.
Is it possible to export some frames to png or another image format?
Or do I have to use an external recording software?

Thanks!

User avatar
Kjell
Posts: 1731
Joined: Sat Feb 23, 2008 11:15 pm

Re: Exporting images from ZGE

Post by Kjell » Tue Dec 09, 2014 6:58 pm

Hi Ats,
Ats wrote:I'd like to make some animated gif from rotating models in ZGE.
If you want to do a clean & consistent rotating GIF it's best to capture the frames from ZGE itself.
Ats wrote:Is it possible to export some frames to png or another image format?
Such feature is not built-in, but it's pretty easy to do by yourself .. attached is a example ( press F to save a frame ) and below is the generated GIF ( from the captured frames ).

Image

K
Attachments
Capture.zgeproj
(3.64 KiB) Downloaded 457 times

User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Mon Jan 12, 2015 9:22 am

I finally had the time to use your image exporter.
But I didn't think that it would take that much time for the processor to make a capture :shock:

I've made some rotating ships and stuff:
Image Image Image
Image Image Image

;) Thank you!

User avatar
Kjell
Posts: 1731
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Mon Jan 12, 2015 9:45 am

Hi Ats,
Ats wrote:I didn't think that it would take that much time for the processor to make a capture
How long does it take to capture a frame on your computer? I get about 15 TGAs per second when i set the KeyPress.RepeatDelay of the Capture example to 0.

By the way, the fighter and interceptor GIFs contain duplicate frames ( the first frame is identical to the last one ) which causes the "hiccup" after each rotation.

And personally i would have gone with flat shading, but that's just a artistic choice :wink:

K

User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Mon Jan 12, 2015 10:49 am

mmm... Even with the KeyPress.RepeatDelay set to 0, it takes almost 3 seconds per frame on your ZGE project to make a capture...
I'm using an Asus Transformer T100 (http://www.engadget.com/products/asus/t ... 100/specs/).

For the flat shading, you are totally right. I'm working on this game from time to time for so long that I don't even remember why I went with smooth shading... I'll make new gif this afternoon :)

Edit: Oh yeah, now I'm remember, that was for the asteroïds. So I'm keeping smooth material only for them.

User avatar
Kjell
Posts: 1731
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Mon Jan 12, 2015 11:22 am

Hi Ats,
Ats wrote:Even with the KeyPress.RepeatDelay set to 0, it takes almost 3 seconds per frame on your ZGE project to make a capture.
That's outrageously slow :? Just tried it on a 10 year old laptop ( with Intel GPU ) and still get 7 frames per second ( held the F key down for a minute and got 422 TGAs ). Are you running anti-virus software or something?

K

User avatar
rrTea
Posts: 426
Joined: Sat Feb 15, 2014 9:54 am
Contact:

Post by rrTea » Mon Jun 08, 2015 3:51 am

It's similarly slow on my 4 or so years old computer too, especialy if the resolution of a project is a bit "higher" (800*600). But I don't particularly mind: it works and it's useful to have it built in. Thanks!

Acer Aspire M3970
Interl i5-2320 @ 3.00GHz
8.00GB
NVidia GeForce GT520 353.06

User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Exporting images from ZGE

Post by Ats » Thu Jul 05, 2018 11:36 am

I'm back at taking screenshots.
So I'm digging through Capture.zgeproj and I have some questions:

How do we know that the exported image is a tga, other than by setting that in the file name?

Code: Select all

FrameFile.FileName = "Frame" + (Frame < 10 ? "0" : "") + intToStr(Frame) + ".tga";
Could that be a friendlier format, like bmp or png?

Is there a size limit for FrameBuffer.SizeDim1? Could 1280x1024 fit in that?

Code: Select all

FrameBuffer.SizeDim1 = FrameWidth * FrameHeight << 2;
Edit: Seems like it does. The problem was coming from my next problem:

Not every exported images are readable. And sometimes the file size can vary (a lot) from one image to another, even if I deactivate the diamond rotation so the images are exactly the same.

Edit: Seems that last one is Dropbox's fault. Since I'm working inside the synchronized Dropbox folder, I had to deactivate it in order to obtain correct screenshot files.

User avatar
Kjell
Posts: 1731
Joined: Sat Feb 23, 2008 11:15 pm

Re: Exporting images from ZGE

Post by Kjell » Fri Jul 06, 2018 1:20 pm

Hi Ats,
Ats wrote:How do we know that the exported image is a tga, other than by setting that in the file name?
Each file format stores data in a specific way .. just changing the file extension from TGA into BMP or PNG doesn't magically transform the data inside the file.
Ats wrote:Could that be a friendlier format, like bmp or png?
The reason why i went with TGA is because it's a very simple file format. You could write a exporter for BMP or PNG as well, but especially PNG is quite a bit of work.

K

User avatar
VilleK
Site Admin
Posts: 2075
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Exporting images from ZGE

Post by VilleK » Wed Jul 29, 2020 1:48 pm

I needed a non-component version of this routine so I'm posting it here for future reference. This routine also need the OpenGL ZExternalLibrary from Kjells project.

Code: Select all

void saveScreenDump(string filename) {
  //Based on code by Kjell http://www.emix8.org/forum/viewtopic.php?f=1&t=1156&p=7242&hilit=save+image#p7242
  int w=App.ViewportWidth;
  int h=App.ViewportHeight;

  byte[18] header;

  header[2] = 2;
  header[16] = 32;
  header[17] = 8;

  header[12] = w;
  header[13] = w >> 8;

  header[14] = h;
  header[15] = h >> 8;

  byte[] image;
  image.SizeDim1=w*h*4;
  glReadPixels(App.ViewportX, App.ViewportY, w, h, 0x80E1, 0x1401, image);

  byte[] buffer;
  buffer.SizeDim1 = header.SizeDim1 + image.SizeDim1;

  int dst=0;
  for(int i=0; i<header.SizeDim1; i++)
    buffer[dst++]=header[i];
  for(int i=0; i<image.SizeDim1; i++)
    buffer[dst++]=image[i];

  @FileAction( File : @File(FileName : filename, Encoding : 1, TargetArray : buffer), Action : 1 );
}

Post Reply