CreateUserBitmap example for Visual Basic
Private Sub Command1_Click()
' allocate memory for a 640x480x24 bpp image
Dim lDataSize As Long
Dim RasterIO As New LEADRasterIO
Dim RasterVar As New LEADRasterVariant
Dim RasterVarEmpty As New LEADRasterVariant
lDataSize = 640# * 480 * 24 / 8
' make sure I am using pixels
LEADRasterView1.ScaleMode = 3
' Create the user bitmap
LEADRasterView1.Raster.CreateUserBitmap 640, 480, 24, RasterVarEmpty, 0
RasterVar.Type = VALUE_ARRAY_BYTE
RasterVar.ItemCount = lDataSize
' fill the bitmap data with gray
For i = 0 To lDataSize - 1
RasterVar.ShortItemValue(i) = 128 ' gray
Next
' set the bitmap data pointer
LEADRasterView1.Raster.SetBitmapDataPointer RasterVar, lDataSize
' save the bitmap
RasterIO.Save LEADRasterView1.Raster, "d:\temp\gray.jpg", FILE_JFIF, 0,
25, SAVE_OVERWRITE
' reset the bitmap data pointer, because the BitmapData array
' will be freed when we exit this function
LEADRasterView1.Raster.SetBitmapDataPointer RasterVarEmpty, 0
End Sub
Private Sub Command2_Click()
Dim RasterIO As New LEADRasterIO
RasterIO.Load LEADRasterView1.Raster, "d:\temp\gray.jpg", 0, 0, 1
End Sub