Retrieves information about a FreeBASIC image buffer
- This feature is only available in fbc version 0.20.0 and later.
Syntax
Usage
result = ImageInfo ( [width] [, [height] [, [bypp] [, [pitch] [, [pixdata] [, [imgsize]]]]]] )
Parameters
width
width of image
height
height of image
bypp
bytes per pixel
pitch
bytes needed per scanline
pixdata
pointer to start of pixel data
imgsize
total memory used by image
Return Value
0 on success, or 1 if an invalid header is detected.
Description
ImageInfo provides you with useful information about an image, such as its dimensions and color depth, but also provides you with the information you need to directly access all the pixel data in the pixel buffer.
It also provides the size of image buffer in memory, which is useful for when you want to copy the buffer or store it in a file.
Example
Dim img As Any Ptr, pixdata As Any Ptr, pitch As Integer
'' Create 32-bit screen and image buffer
ScreenRes 320, 200, 32
img = ImageCreate(64, 64)
'' get pitch and pixel data pointer of image
ImageInfo img, ,,, pitch, pixdata
'' draw pattern directly into the image memory
For y As Integer = 0 To 63
Dim As UInteger Ptr p = pixdata + y * pitch
For x As Integer = 0 To 63
p[x] = RGB(x * 4, y * 4, (x Xor y) * 4)
Next x
Next y
'' Put the image to screen
Put (10, 10), img
'' Free the image memory
ImageDestroy img
'' Wait for a keypress before closing
Sleep
Dialect Differences
- Not available in the -lang qb dialect unless referenced with the alias __Imageinfo.
Differences from QB
See also