PNG screenshots

Previous topic - Next topic

Synthetic

This creates screenshots in the PNG format. There would be more to say but that's all it does.

=======================
Notes
=======================
When this example starts, it allows you to take only one screen shot with the "=" key. You will find the
screenshot inside the same folder as this example binary named screenshot.png.

Please note there is NO error handling. If something screws up, especially with libpng, you will get
a program crash.

When calling the screenshot_png function, it will automatically determine your screen size. You only
have to supply a file name or a folder/directory along with file name you want to save the screenshot
as.

All required headers are included and should be placed in the same folder where your source is located.
They are:
_mingw.h | stdarg.h | stddef.h | stdint.h | stdio.h | stdlib.h | and the sys folder with types.h

=======================
Usage
=======================
screenshot_png("something/screenshot.png")

=======================
Arguments
=======================
file$ - The name and path/name for the PNG image you would like to create.

=======================
Other
=======================
Feel free to use, chop up or mangle this code for your own usage. It is supplied AS-IS and should be
used at your own risk!

I will probably add more to this such as PNG text info customizing etc and I'm always open to ideas.

[attachment deleted by admin]
"Impossible is a word people use to make themselves feel better when they quit."

My AMXMODX plugins for Day of Defeat 1.3 can be found here.

D2O

Hmm, ohne Deine Arbeit zu schm?lern, aber das kann doch das 'SAVEBMP "myfolder/myscreen.png"' doch auch.

Oder habe ich das Falsch verstanden?
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

Synthetic

As far as I know, it and savesprite only saves BMP files which is why I made it but maybe there was an update I didn't notice. I needed something smaller for screenshots.
"Impossible is a word people use to make themselves feel better when they quit."

My AMXMODX plugins for Day of Defeat 1.3 can be found here.

Moru

Is it possible to save an alpha channel into the PNG with this code?

Synthetic

Sure is but with some modifications. In the glReadPixels call, you will need to change GL_RGB to GL_RGBA and un-comment out the GL_RGBA define. Also, the PNG_COLOR_TYPE define needs to be changed from 2 to 2 | 4.
"Impossible is a word people use to make themselves feel better when they quit."

My AMXMODX plugins for Day of Defeat 1.3 can be found here.

Synthetic

I take that back, don't bother with the OpenGL stuff. My brain is not functioning right this morning. XD  There is a function to set the alpha value, I just don't remember it off hand atm. I'll post back when I find it.
"Impossible is a word people use to make themselves feel better when they quit."

My AMXMODX plugins for Day of Defeat 1.3 can be found here.

Hemlos

ALPHAMODE 1  // [-1.000..1.000]
Bing ChatGpt is pretty smart :O

Moru

Quote from: Hemlos on 2009-Sep-27
ALPHAMODE 1  // [-1.000..1.000]

This is not about displaying PNG's, Hemlos... read the thread please

Hemlos

Quote from: Moru on 2009-Sep-27
Quote from: Hemlos on 2009-Sep-27
ALPHAMODE 1  // [-1.000..1.000]

This is not about displaying PNG's, Hemlos... read the thread please

Sorry, need to elaborate;
the alphamode previously set, is sent "mixed" to the file.

Bing ChatGpt is pretty smart :O

Kitty Hello

Quote from: Synthetic on 2009-Sep-26
As far as I know, it and savesprite only saves BMP files which is why I made it but maybe there was an update I didn't notice. I needed something smaller for screenshots.
Savesprite also saves PNG images (with alpha information). You can resize an image with CREATESCREEN and STRETCHSPRITE.