CreateUserBitmap2 example for Visual Basic
Private Sub Command1_Click()
' allocate memory for a 640x480x24 bpp image
Dim lDataSize As Long
Dim BitmapData(640# * 480 * 24 / 8) As Byte
Dim RasterIO As New LEADRasterIO
lDataSize = 640# * 480 * 24 / 8
' make sure I am using pixels
LEADRasterView1.ScaleMode = 3
' Create the user bitmap
LEADRasterView1.Raster.CreateUserBitmap2 640, 480, 24, Empty, 0
' fill the bitmap data with gray
For i = 0 To lDataSize - 1
BitmapData(i) = 128 ' gray
Next
' set the bitmap data pointer
LEADRasterView1.Raster.SetBitmapDataPointer2 BitmapData, 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.SetBitmapDataPointer2 Empty, 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