Author Topic: PNG screenshots  (Read 3646 times)

Offline Synthetic

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
    • ClanBam
PNG screenshots
« on: 2009-Sep-24 »
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.

Offline D2O

  • Prof. Inline
  • *****
  • Posts: 1066
    • View Profile
    • http://www.deuteriumoxid.com
Re: PNG screenshots
« Reply #1 on: 2009-Sep-25 »
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

Offline Synthetic

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
    • ClanBam
Re: PNG screenshots
« Reply #2 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.
"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.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1783
    • View Profile
    • Homepage
Re: PNG screenshots
« Reply #3 on: 2009-Sep-26 »
Is it possible to save an alpha channel into the PNG with this code?

Offline Synthetic

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
    • ClanBam
Re: PNG screenshots
« Reply #4 on: 2009-Sep-26 »
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.

Offline Synthetic

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
    • ClanBam
Re: PNG screenshots
« Reply #5 on: 2009-Sep-26 »
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.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: PNG screenshots
« Reply #6 on: 2009-Sep-27 »
ALPHAMODE 1  // [-1.000..1.000]
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1783
    • View Profile
    • Homepage
Re: PNG screenshots
« Reply #7 on: 2009-Sep-27 »
ALPHAMODE 1  // [-1.000..1.000]

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

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: PNG screenshots
« Reply #8 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.

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10726
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: PNG screenshots
« Reply #9 on: 2009-Sep-28 »
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.