为什么biClrUsed总是为零? [英] How come biClrUsed is always zero?
问题描述
下面的代码与预期相同。
例如
biSize = 40
但biClrUsed总是为零!
InBitmap.Palette.Entries.Length具有预期值
GetObject成功
有什么建议吗?
非常感谢
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSec As New Wnd.DIBSECTION
Dim dibSecPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
如果Wnd.GetObject(hInBitmap,Marshal.SizeOf(dibSec),dibSecPtr)<>
Marshal.SizeOf(dibSec)然后
''???发布hInBitmap ???
退出Sub
结束如果
dibSec = CType(Marshal.PtrToStructure(dibSecPtr,dibSec.GetType),
Wnd .DIOOKECTION)
Dim NColor作为整数
''??? dibS ec.dsBmih.biClrUsed总是为零???
如果.biClrUsed 0那么
NColor = CInt(.biClrUsed)>
ElseIf .biBitCount< 24然后
NColor = 1<< .biBitCount
否则
''???如果我们到这里,这可能不是24岁吗?
NColor = 0
结束如果
结束
NColor = InBitmap.Palette.Entries.Length
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
推荐答案
Dim hInBitmap作为IntPtr = InBitmap.GetHbitmap()
上面总是返回一个32bpp的位图。
32bpp位图没有颜色表,因此biClrUsed会永远是0.
"活性" < ac ********** @ a-znet.com写了留言
新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
The above always returns a 32bpp bitmap.
32bpp bitmaps have no color table and therefore biClrUsed will always be 0.
" active" <ac**********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
下面的代码与预期的相同。
例如
biSize = 40
但是biClrUsed总是为零!
InBitmap.Palette.Entries.Length有预期值
Marshal.SizeOf(dibSec))84是预期的
GetObject成功
有什么建议吗?
非常感谢
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSec As New Wnd.DIBSECTION
Dim dibSecPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
如果Wnd.GetObject(hInBitmap,Marshal.SizeOf(dibSec),dibSecPtr)<>
Marshal.SizeOf(dibSec)那么
''? ??发布hInBitmap ???
退出Sub
结束如果
dibSec = CType (Marshal.PtrTo结构(dibSecPtr,dibSec.GetType),
Wnd.DIBSECTION)
Dim NColor作为整数
' '??? dibSec.dsBmih.biClrUsed总是为零???
如果.biClrUsed 0那么
NColor = CInt(.biClrUsed) )
ElseIf .biBitCount< 24然后
NColor = 1<< .biBitCount
否则
''???如果我们到这里,这可能不是24岁吗?
NColor = 0
结束如果
结束
NColor = InBitmap.Palette.Entries.Length
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
>
我正在尝试将8bpp放在剪贴板上
I''m trying to put a 8bpp on the clipboard
>如果你传递CreateDIBSection创建的句柄
>You can if you pass a handle created by CreateDIBSection
我正在尝试为CreateDIBSection生成参数
无法通过GetObject
" Michael Phillips,Jr。 < mp ********* @ nospam.jun0.c0mwrote in message
news:Og ************** @ TK2MSFTNGP04.phx。 gbl ...
I''m trying to generate the arguments for CreateDIBSection
Can''t get past GetObject
"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:Og**************@TK2MSFTNGP04.phx.gbl...
> Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
>Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
上面总是返回一个32bpp的位图。
The above always returns a 32bpp bitmap.
我不明白系统的作用。
我要求一个句柄和8bpp它必须生成一个新的位图某个地方
那是'32bpp并给我一个处理。这是正确的吗?
它是在非托管内存中创建的吗?
该内存何时释放回系统?
它只是它只能处理32bpp,除了它可以接受其他
布局作为输入吗?
感谢您的帮助
I don''t understand what the System does.
I ask for a handle to and 8bpp and it must generate a new bitmap someplace
that''s 32bpp and give me a handle to that. Is that correct?
It is created in unmanaged memory right?
When is that memory released back to the system?
Is it simply that it can only handle 32bpp except that it can accept other
layouts as input?
Thanks for helping
>
32bpp位图没有颜色表,因此biClrUsed总是
0.
活性" < ac ********** @ a-znet.com写了留言
新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...
>
32bpp bitmaps have no color table and therefore biClrUsed will always be
0.
" active" <ac**********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>下面的代码与预期相同。
例如
biSize = 40
但biClrUsed总是为零!
InBitmap.Palette.Entries.Length具有预期值
Marshal.SizeOf( dibSec))84是如预期的那样
GetObject成功
有什么建议吗?
非常感谢
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSecPtr作为IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
如果Wnd.GetObject(hInBitmap,Marshal.SizeOf(dibSec),dibSecPtr)<>
Marshal.SizeOf(dibSec)那么
''???释放hInBitmap ???
退出Sub
结束如果
dibSec = CType(Marshal.PtrToStructure(dibSecPtr,dibSec.GetType),
Wnd.DIBSECTION)
Dim NColor作为整数
''???dibSec.dsBmih.biClrUsed总是为零???
如果.biClrUsed 0那么
NColor = CInt(.biClrUsed)>
ElseIf .biBitCount< 24然后
NColor = 1<< .biBitCount
其他
''???如果我们到这里,这可能不是24岁吗?
NColor = 0
结束如果
结束
NColor = InBitmap.Palette.Entries.Length
>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
我已经一直在搜索互联网,无法找到任何人使用
CreateDIBSection为剪贴板创建句柄的示例。你不会碰巧
你知道什么吗?
据我所知,如果我将8bpp放在剪贴板上它会被转换
到32bpp。
但是如果我创建原始的DIBSection副本并在剪贴板上放置一个句柄
然后剪贴板上会有8bpp。是的。
谢谢
Michael Phillips,Jr。 < mp ********* @ nospam.jun0.c0mwrote in message
news:Og ************** @ TK2MSFTNGP04.phx。 gbl ...
I''ve been searching the Internet and can''t find an example of anyone using
CreateDIBSection to create a handle for the clipboard. You don''t happen to
know of anything do you?
As I understand it, if I put my 8bpp on the clipboard it will be converted
to 32bpp.
But if I create a DIBSection copy of the original and put a handle to that
on the clipboard there will then be an 8bpp on the clipboard. Right.
Thanks
"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:Og**************@TK2MSFTNGP04.phx.gbl...
> Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
>Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
上面总是返回一个32bpp的位图。
32bpp位图没有颜色表,因此biClrUsed总是
0。 />
"活性" < ac ********** @ a-znet.com写了留言
新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...
The above always returns a 32bpp bitmap.
32bpp bitmaps have no color table and therefore biClrUsed will always be
0.
" active" <ac**********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>下面的代码与预期相同。
例如
biSize = 40
但biClrUsed总是为零!
InBitmap.Palette.Entries.Length具有预期值
Marshal.SizeOf( dibSec))84是如预期的那样
GetObject成功
有什么建议吗?
非常感谢
Dim hInBitmap As IntPtr = InBitmap.GetHbitmap()
Dim dibSecPtr作为IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dibSec))
如果Wnd.GetObject(hInBitmap,Marshal.SizeOf(dibSec),dibSecPtr)<>
Marshal.SizeOf(dibSec)那么
''???释放hInBitmap ???
退出Sub
结束如果
dibSec = CType(Marshal.PtrToStructure(dibSecPtr,dibSec.GetType),
Wnd.DIBSECTION)
Dim NColor作为整数
''???dibSec.dsBmih.biClrUsed总是为零???
如果.biClrUsed 0那么
NColor = CInt(.biClrUsed)>
ElseIf .biBitCount< 24然后
NColor = 1<< .biBitCount
其他
''???如果我们到这里,这可能不是24岁吗?
NColor = 0
结束如果
结束
NColor = InBitmap.Palette.Entries.Length
>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
这篇关于为什么biClrUsed总是为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!