A
active
The code below does much as expected.
For example
biSize=40
but biClrUsed is always zero!
InBitmap.Palette.Entries.Length has the expected value
Marshal.SizeOf(dibSec)) is 84 as expected
GetObject succeeds
Any suggestions?
Thanks a lot
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSec As New Wnd.DIBSECTION
Dim dibSecPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
If Wnd.GetObject(hInBitmap, Marshal.SizeOf(dibSec), dibSecPtr) <>
Marshal.SizeOf(dibSec) Then
'???release hInBitmap???
Exit Sub
End If
dibSec = CType(Marshal.PtrToStructure(dibSecPtr, dibSec.GetType),
Wnd.DIBSECTION)
Dim NColor As Integer
'???dibSec.dsBmih.biClrUsed is always zero???
If .biClrUsed > 0 Then
NColor = CInt(.biClrUsed)
ElseIf .biBitCount < 24 Then
NColor = 1 << .biBitCount
Else
'??? Can this be other than 24 if we get here???
NColor = 0
End If
End With
NColor = InBitmap.Palette.Entries.Length
For example
biSize=40
but biClrUsed is always zero!
InBitmap.Palette.Entries.Length has the expected value
Marshal.SizeOf(dibSec)) is 84 as expected
GetObject succeeds
Any suggestions?
Thanks a lot
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSec As New Wnd.DIBSECTION
Dim dibSecPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
If Wnd.GetObject(hInBitmap, Marshal.SizeOf(dibSec), dibSecPtr) <>
Marshal.SizeOf(dibSec) Then
'???release hInBitmap???
Exit Sub
End If
dibSec = CType(Marshal.PtrToStructure(dibSecPtr, dibSec.GetType),
Wnd.DIBSECTION)
Dim NColor As Integer
'???dibSec.dsBmih.biClrUsed is always zero???
If .biClrUsed > 0 Then
NColor = CInt(.biClrUsed)
ElseIf .biBitCount < 24 Then
NColor = 1 << .biBitCount
Else
'??? Can this be other than 24 if we get here???
NColor = 0
End If
End With
NColor = InBitmap.Palette.Entries.Length