Skip to content

SaveBuffer

Narta Xaymar Dirks edited this page Oct 31, 2026 · 7 revisions

Blitz3DBlitzPlusBlitzBasic

SaveBuffer

SaveBuffer:Int32 buffer:Int32, bmpfile:String
Parameter Mode Type Default Description
buffer In Int32 required The buffer to save.
bmpfile In String required The path of the file to write.

Returns: 1 if the file was written, otherwise 0. With AsyncSaving on, 1 means that the save was queued, see SavesFailed.

Description

Writes the content of a buffer into a picture file. Saving the front buffer after a Flip makes a screenshot. The format comes from the end of the file name: .bmp, .png, .jpg (or .jpeg), .webp, .jxl, .tga and .dds are written, and a name with any other ending is a BMP, as every name was in the original. .avif is refused (the result is 0), because the encoder for it would about double the size of every program. The optional settings choose how the file is made, for example the quality of a JPEG, see Saving pictures for all of them.

Differences

  • The original only writes BMP files. Here the ending of the name picks PNG, JPEG, WebP, JPEG XL, TGA, DDS or BMP, the settings argument is new, and files other than BMP and TGA say which program made them.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Cls
Color 255, 255, 255
Text 160, 120, "Screenshot", 1, 1
Flip
If SaveBuffer(FrontBuffer(), "screenshot.bmp") Then Print "saved" Else Print "failed"
SaveBuffer FrontBuffer(), "screenshot.png"
SaveBuffer FrontBuffer(), "screenshot.jpg", "quality=80, progressive=1"
SaveBuffer FrontBuffer(), "screenshot.jxl", "lossless=1"
SaveBuffer FrontBuffer(), "screenshot.dds", "format=bc7, mipmaps=1"
WaitKey

Related Commands

BackBuffer, BufferDirty, FrontBuffer, GraphicsBuffer, LoadBuffer, LockBuffer, SetBuffer, UnlockBuffer

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally