Png save

From Bennu Wiki
Jump to: navigation, search


Definition

INT png_save ( <INT fileID> , <INT graphID> , <STRING filename> )

Saves the specified graphic as filename with the format PNG.

The previous name save_png() is deprecated.

Parameters

INT fileID - The fileID of the file that holds the graphic.
INT graphID - The graphID of the graphic to save.
STRING filename - The name of the PNG file to be saved, including a possible path.

Returns

INT : Successrate

false - Error.
true - Success.

Example

//here's a cool thing to save a screenshot
import "mod_map"
import "mod_screen"
import "mod_key"

Global
    int takingscreenshot;
End

Process Main()
Begin

    Loop
        
        If (key(_F12)) 
            If (takingscreenshot==0)
                takingscreenshot=1;
                graph=screen_get(); // grabs the screen and sets it as the program graphic
                png_save(0,graph,"shot"+rand(0,9999)+".png"); // saves the graphic as a png with a
                                                              // random number in the filename to
                                                              // prevent overwriting 
                map_unload(0,graph);  //frees the graphic
            Else
                takingscreenshot=0;
            End
            While(key(_F12)) Frame; End
       End

        frame;
    End
End

Used in example: key(), screen_get(), png_save(), map_unload()


Mod_map
Globals None
Imported:
FullscreenGraphmodeM7ScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants BCLEARCHARSETCP850CHARSETISO8859GANIMATIONSPEEDGANIMATIONSTEPGANIMATIONSTEPSGCENTERXGCENTERYGDEPTHGFRAMESGHEIGHTGPITCHGWIDEGWIDTHGXCENTERGYCENTERNFBFIXEDWIDTHNFBVARIABLEWIDTH
Imported:
BABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOW
Functions Bdfload()Centerset()Colorfind()Colorsget()Colorsset()Fade()Fadeoff()Fadeon()Fntload()Fntnew()Fntsave()Fntunload()Fpgadd()Fpgdel()Fpgexists()Fpgload()Fpgnew()Fpgsave()Fpgunload()Getpixel()Glyphget()Glyphset()Graphicinfo()Graphicset()Mapblockcopy()Mapbuffer()Mapclear()Mapclone()Mapdel()Mapexists()Mapgetpixel()Mapinfo()Mapinfoget()Mapinfoset()Mapload()Mapname()Mapnew()Mapput()Mapputpixel()Mapsave()Mapsetname()Mapunload()Mapxput()Mapxputnp()Palclone()Paldel()Palget()Palload()Palmapassign()Palmapgetid()Palmapremove()Palnew()Palrefresh()Palsave()Palset()Palunload()Paletteconvert()Paletteroll()Pcxload()Pngload()Pngsave()Pointget()Pointset()Putpixel()Rgb()Rgbget()Rgba()Rgbaget()