显示用于图像缓冲区的两个不同标题的示例。
注意:
ImageInfo作为直接读取图像结构的更简单的替代方案。
'' fbgfx.bi contains the necessary structures and constants for working
'' directly with image headers
#include "fbgfx.bi"
'' in lang fb, structures and constants are contained in the FB namespace
#if __FB_LANG__ = "fb"
Using FB
#endif
'' function to show info on an image
Sub show_image_info( ByVal image As Any Ptr )
Dim As PUT_HEADER Ptr header
Dim As Integer w, h, bpp, pitch
header = image
If( header->Type = PUT_HEADER_NEW ) Then
Print "New style header"
w = header->Width
h = header->height
bpp = header->bpp
pitch = header->pitch
Else
Print "Old style header"
w = header->old.width
h = header->old.height
bpp = header->old.bpp
pitch = w * bpp
End If
Print "Image dimensions are " & w & "*" & h
Print "Image uses " & bpp & " bytes for each pixel"
Print "A row of image pixels takes " & pitch & " bytes"
End Sub
Dim As Any Ptr picture
ScreenRes 320, 200, 32
picture = ImageCreate( 10, 10, RGB(128, 192, 255) )
Put( 40, 40 ), picture, PSet
show_image_info( picture )
ImageDestroy picture
Sleep
注意:要将此代码与数组一起使用,请将数组传递给函数,如下所示:
show_image_info( VarPtr( myarray( L ) ) )
其中L是myarray()的下限。