b2dGrabImage

Category: 2D Overlay

Syntax:

b2dGrabImage:Int(x1:Int, y1:Int, x2:Int, y2:Int)


Parameters

Returns

Int



Summary

Captures a rectangle of what has been drawn so far and returns it as a new image. In this edition it reads the backbuffer - the frame on screen - and no b2dFlush call is needed first.

Takes x1, y1 (top-left corner of the region, in pixels) and x2, y2 (the bottom-right corner, in pixels - these are coordinates, not a width and height). The corners may be given in either order. A zero-width or zero-height region fails, so passing 0 for x2 or y2 does not mean "to the far edge".

Returns a new image handle (a positive integer), or 0 on failure.

The image returned can be a different size from the region asked for. The region is mapped out of the program's coordinate space onto the surface and clamped to it, so on a screen larger or smaller than the requested resolution the result comes back larger or smaller to match what is actually on screen. Always read the size back with b2dGetImageWidth and b2dGetImageHeight rather than assuming it is x2-x1 by y2-y1.

View detailed documentation online



Example

;No example implemented yet


BambooBasic © 2026 Michael Denathorn