Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Best way to capture screen and save to image file

This thread is locked; no one can reply to it. rss feed Print
Best way to capture screen and save to image file
dalleg
Member #14,731
November 2012

Hello,

I am working with Allegro 4.2 and DJGPP.
In my program I do a screen capture (by blitting screen to a memory bitmap) and then save the file with save_bitmap(...).
As I use 1280*1024 resolution, 16bit depth, it gives a nice 3.8megs file.

This works fine but the .bmp files are way too heavy. So I tried to find out a SIMPLE way to save those screen pictures, without any loss, but with much smaller size (which means compression)

First I tried the .tga file format but as I expected it does not compress.
I looked for another interesting image format and it seems that .png is a good one : nice compression, no losses.
So I went on internet and found the Alpng library. I installed it and I am now able to use save_png() function.
But then I undestood that this library alone does not do any compression in the png file... I may need zlib or libpng or...

So my question is :
What is the easiest way to save good quality picture (and reload it after), with not-too-big storage size ?
Do I really need extra library ?

Thanks.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

dalleg said:

I am working with Allegro 4.2 and DJGPP.

Allegro 4.2 is old, even for Allegro 4. You want version 4.4.2, the latest version of allegro 4. Go back to the files page.

Also DJGPP is only for DOS, so unless you know what you're doing, you should be using MinGW for Windows.

Also, Allegro 4.4 comes with loadpng library installed, and it has save-ability too if I remember correctly, but with compression enabled. There's also jpgalleg if you don't mind lossy compression.

dalleg
Member #14,731
November 2012

Hello Edgar,

Well I work under DOS, and that's why I use DGJPP
Also that's why I have 4.2 version (I mean 4.2.3 or something like that), as on Allegro main page I don't clearly see that the 4.4 version supports DOS.

And I want to have the possibility to save the screen without any loss, so I guess jpgalleg will not help (?)

Audric
Member #907
January 2001

Have you tried allegro's own save_pcx() ? The format is run-length encoded horizontally. It's recognized by popular image viewers. (edit: and especially DOS software)

Thomas Fjellstrom
Member #476
June 2000
avatar

dalleg said:

But then I undestood that this library alone does not do any compression in the png file... I may need zlib or libpng or...

PNG does compress. It actually uses zlib compression on the image data. I don't even know if there is a raw uncompressed version of png.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Luiji99
Member #12,254
September 2010

Uncompressed data is possible, just not un-deflated. http://drj11.wordpress.com/2007/11/20/a-use-for-uncompressed-pngs/

Programming should be fun. That's why I hate Java.

dalleg
Member #14,731
November 2012

Hello,

I confirm that when you use save_png() function alone, without zlib, you get a .png which has exactly the same size as a .bmp. I did test it.

Audric
=> I hadn't really tested with .pcx, and you're right, it seems to be a solution. Maybe the compression is not amazing, but acceptable.
I didn't really know what to do with this .pcx format, but then I found "XnView" software, which is very nice, with it I can convert a batch of .pcx to .png.
So, this is a solution! Maybe not the best, but for what I want to do now, it's good enough.

And then I suppose that if I want to use directly .png I'll have to install zlib and/or libpng...

Go to: