Retrieves information about an image
Syntax
Usage
result = ImageInfo( image [, [width] [, [height] [, [bypp] [, [pitch] [, [pixdata] [, size]]]]]] )
Parameters
image
The address of the image.
width
Stores the width of the image, in pixels.
height
Stores the height of the image, in pixels.
bypp
Stores the bytes per pixel of the image - i.e. the size of a single pixel, in bytes.
pitch
Stores the pitch of the image - i.e. the size of each scanline (row), in bytes. Note that this may be more than just width * bypp, because the scanlines may be padded to allow them to be aligned better in memory.
pixdata
Stores the address of the start of the first scanline of the image.
size
Stores the size of the image in memory, in bytes.
Return Value
If image doesn't point to a valid image, one (1) is returned. Otherwise, width, height, bypp, pitch, pixdata and size are assigned appropriate values, and zero (0) is returned.
Description
ImageInfo provides various 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 can also provide the size of the image in memory, which is useful for allocating memory to copy the existing image, or to write the image to a file.
Example
'' Create 32-bit graphics screen and image.
ScreenRes 320, 200, 32
Dim image As Any Ptr = ImageCreate( 64, 64 )
Dim pitch As Integer
Dim pixels As Any Ptr
'' Get enough information to iterate through the pixel data.
If 0 <> ImageInfo( image, ,,, pitch, pixels ) Then
Print "unable to retrieve image information."
Sleep
End
End If
'' Draw a pattern on the image by directly manipulating pixel memory.
For y As Integer = 0 To 63
Dim row As UInteger Ptr = pixels + y * pitch
For x As Integer = 0 To 63
row[x] = RGB(x * 4, y * 4, (x Xor y) * 4)
Next x
Next y
'' Draw the image onto the screen.
Put (10, 10), image
ImageDestroy( image )
Sleep
Dialect Differences
- Not available in the -lang qb dialect unless referenced with the alias __Imageinfo.
Differences from QB
See also