Blitz3D+ Command Reference

LoadBuffer ( buffer,bmpfile$ )

Parameters

buffer - buffer to load the picture into, such as BackBuffer() or ImageBuffer(pic)

bmpfile$ - path to the image file to load

Description

Loads an image straight into a buffer, stretching it to fit. Returns True on success, False if the file could not be loaded.

Where LoadImage gives you a handle to keep, this paints the picture into a surface and hands you nothing to hold on to - so it suits pictures you show once and never manage: a splash screen, a loading backdrop, a level's static background, an end-of-game screen.

The picture is scaled to the buffer's exact size, which is convenient for full-screen art but will squash anything whose shape does not match your display. Prepare backgrounds at the resolution you run at, or accept the stretch.

It works on any buffer: FrontBuffer() to put something on screen immediately without a Flip, BackBuffer() to have it appear on the next flip, or an ImageBuffer to fill an existing image, which doubles as a quick way to rescale a picture to a chosen size.

The same file formats as LoadImage are accepted. Loading into the back buffer is not permanent - the next Cls wipes it - so redraw or grab it with GrabImage if you need it to persist.

See also: SaveBuffer, LoadImage, SetBuffer, ImageBuffer, GrabImage.

Example

; LoadBuffer Example
; ------------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

; Prefer the screenshot made by the SaveBuffer example, if it exists
If FileType("demo_screenshot.bmp")=1 Then
    file$="demo_screenshot.bmp"
Else
    file$="media/b3dlogo.jpg"
End If

While Not KeyDown(1)

    ; LoadBuffer paints the file straight onto a buffer, scaled to fit -
    ; no image handle involved. It returns 1 on success, 0 on failure.
    ok=LoadBuffer(BackBuffer(),file$)

    Text 0,0,"Esc: exit"
    Text 0,20,"LoadBuffer filled the back buffer from "+file$+" (returned "+ok+")"
    If file$="media/b3dlogo.jpg" Then
        Text 0,40,"Tip: run the SaveBuffer example and press S to create demo_screenshot.bmp"
    End If

    Flip

Wend

End

Index