CreateDIBitmap function in vb.net. Help!!!

  • Thread starter Thread starter blensm
  • Start date Start date
B

blensm

Hi,

I'm using CreateDIBitmap function from Windows Api and I have a
problem in vb.net:
The following error raises: "It cann't calculate references from
bmiColors field from BITMAPINFO type:..."
I don't know what happens. Have anyone used this function in vb.net
sometimes?

'DECLARATIONS

Public Structure BITMAPINFO
Public bmiHeader As BITMAPINFOHEADER
Public bmiColors() As RGBQUAD
End Structure
Public Structure RGBQUAD
Public rgbBlue As Byte
Public rgbGreen As Byte
Public rgbRed As Byte
Public rgbReserved As Byte
End Structure

' structures for defining DIBs

Public Structure BITMAPINFOHEADER '40 bytes
Public biSize As Integer
Public biWidth As Integer
Public biHeight As Integer
Public biPlanes As Short
Public biBitCount As Integer
Public biCompression As Integer
Public biSizeImage As Integer
Public biXPelsPerMeter As Integer
Public biYPelsPerMeter As Integer
Public biClrUsed As Short
Public biClrImportant As Integer
End Structure

-------------------------------------------------
Dim rgbQuad As RGBQUAD
Dim array(255) As RGBQUAD
'Setting RGBQUAD
For i = 0 To (2 ^ 8 - 1)
rgbQuad.rgbBlue = i
rgbQuad.rgbRed = i
rgbQuad.rgbGreen = i
rgbQuad.rgbReserved = 0
array(i) = rgbQuad
Next i

ReDim bm.bmiColors(255)

For i = 0 To (2 ^ 8 - 1)
bm.bmiColors(i) = New RGBQUAD()
bm.bmiColors(i) = array(i)
Next

'Assigning value to the Bitmap Header
'With bm.bmiHeader
Dim header As BITMAPINFOHEADER

header.biSize = Len(bm.bmiHeader)
header.biWidth = nWidth
header.biHeight = nHeight
header.biPlanes = 1
header.biBitCount = 8
header.biCompression = BI_RGB
header.biSizeImage = 0
header.biXPelsPerMeter = 0
header.biYPelsPerMeter = 0
header.biClrUsed = 0
header.biClrImportant = 0

bm.bmiHeader = header
'Get the DC.
hDC = GetDC(0&)
'Creating Device Independent Bitmap

hBMP = CreateDIBitmap(hDC, bm.bmiHeader, CBM_INIT,
pixelData(0), bm, DIB_RGB_COLORS)


I need help, please!!!!!
Thanks in advance.

Belén
 
Back
Top