如何显示DIB或将其绘制到位图中 [英] How to display a DIB or draw it into a Bitmap

查看:77
本文介绍了如何显示DIB或将其绘制到位图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在互联网上寻找将DIB转换为位图的方法

但没有成功。


现在我是想知道这是否是我应该采取的方法。


我想要做的就是显示DIB或将其绘制成位图。


是否有图形方法可以提供帮助?


感谢

解决方案

System.Drawing.Bitmap对象是DIB。如果你想要一个DDB,请使用

GetHbitmap。如果你想用现有的DIB用CreateDIBSection或GDI DDB句柄构建一个Bitmap,请使用

构造函数之一的Bitmap类。


使用Graphics方法DrawImage显示或转换为不同的

PixelFormat。


如果你想与本机一起工作GDI API,然后使用CreateBitmap创建

a DDB或使用CreateDIBSection创建DIB。


要将一个转换为另一个,请使用BitBlt或任何一个其他GDIBitBlt

变种。


"活性" < ac ********** @ a-znet.comwrote in message

news:uk ************** @ TK2MSFTNGP04.phx .gbl ...


我一直在互联网上寻找将DIB转换为位图的方法

但没有成功。


现在我想知道这是否是我应该采取的方法。


我想做的就是显示DIB或者将它绘制成一个位图。


是否有图形方法可以提供帮助?


感谢



当我不问这个问题时,我讨厌它。


我想从剪贴板中获取DIB。


剪贴板产生的是一个MemoryStream。


我已经读过该流并获得了DIB中的调色板。


现在我想得到一个我认为很难从

流中读取的位图,因为它有很多变化。


我想这个这与将位图从文件

读入位图相同。


这就是我一直在寻找的东西。

谢谢


" Michael Phillips,Jr。" < mp ********* @nospam.jun0.c0mwrote in message

news:ew ************** @ TK2MSFTNGP04.phx。 gbl ...


System.Drawing.Bitmap对象是DIB。如果你想要一个DDB,请使用

GetHbitmap。如果要从使用CreateDIBSection或GDI DDB句柄创建的现有DIB

构造位图,请使用Bitmap类的

构造函数之一。


使用Graphics方法DrawImage显示或转换为不同的

PixelFormat。


如果你想与本机一起工作GDI API,然后使用CreateBitmap来创建一个DDB或使用CreateDIBSection创建一个DIB。


要将一个转换为另一个,请使用BitBlt或任何另一个GDIBitBlt

变种。


"活性" < ac ********** @ a-znet.comwrote in message

news:uk ************** @ TK2MSFTNGP04.phx .gbl ...


>我一直在互联网上寻找将DIB转换为位图的方法,但没有成功。

现在我想知道这是否是我应该采取的方法。

我想要做的就是显示DIB或将其绘制到位图中。

是否有图形方法可以提供帮助?



剪贴板产生的是一个MemoryStream。


您可以按原样从MemoryStream对象构造一个Bitmap对象。使用

使用流对象作为参数的Bitmap构造函数或方法。

"活性" < ac ********** @ a-znet.comwrote in message

news:up ************** @ TK2MSFTNGP05.phx .gbl ...


>当我不问这个问题时,我讨厌它。


我想要从剪贴板中获取DIB。


剪贴板产生的是一个MemoryStream。


我已经读过那个流并获得了调色板在DIB。


现在我想得到一个我认为很难从

流中读取的位图,因为它有很多变化。


我想在这一点上它与将位图从一个文件

读入一个位图是一样的。


这就是我一直在寻找的。


谢谢


Michael Phillips,Jr。 < mp ********* @nospam.jun0.c0mwrote in message

news:ew ************** @ TK2MSFTNGP04.phx。 gbl ...


> System.Drawing.Bitmap对象是DIB。如果你想要一个DDB,请使用GetHbitmap。如果要从使用CreateDIBSection或GDI DDB句柄创建的现有DIB构造位图,请使用Bitmap类的
构造函数之一。

使用Graphics方法DrawImage显示或转换为不同的PixelFormat。

如果你想使用原生GDI API,那么使用CreateBitmap创建一个DDB或使用CreateDIBSection来创建一个DIB。

要将一个转换为另一个,请使用BitBlt或任何其他GDIBitBlt
变体。

"活性" < ac ********** @ a-znet.com在留言中写道
新闻:英国************** @ TK2MSFTNGP04.phx.gbl .. 。


>>我一直在互联网上寻找将DIB转换为位图的方法,但没有成功。

现在我想知道这是否是我应该采取的方法。

我想要做的就是显示DIB或将其绘制成位图。

是否有图形方法可以提供帮助?





I''ve been looking on the Internet for a way to convert a DIB to a Bitmap
without success.

Now I''m wondering if that is the approach I should be taking.

All I want to do is display the DIB or draw it into a Bitmap.

Is there a graphics method that can help?

thanks

解决方案

The System.Drawing.Bitmap object is a DIB. If you want a DDB, use
GetHbitmap. If you want to construct a Bitmap from an existing DIB created
with CreateDIBSection or a GDI DDB handle, use one of the constructors of
the Bitmap class.

Use the Graphics method DrawImage to display or convert to a different
PixelFormat.

If you want to work with the native GDI API, then use CreateBitmap to create
a DDB or use CreateDIBSection to create a DIB.

To convert one to the other, use BitBlt or any of the other GDI "BitBlt"
variations.

" active" <ac**********@a-znet.comwrote in message
news:uk**************@TK2MSFTNGP04.phx.gbl...

I''ve been looking on the Internet for a way to convert a DIB to a Bitmap
without success.

Now I''m wondering if that is the approach I should be taking.

All I want to do is display the DIB or draw it into a Bitmap.

Is there a graphics method that can help?

thanks



I hate it when I don''t ask the question right.

I want to get a DIB from the clipboard.

What the clipboard produces is a MemoryStream.

I have read that stream and obtained the palette in the DIB.

Now I''d like to get the bitmap which I think is harder to read from the
stream because there are so many variations.

I suppose at this point it is the same as reading the bitmap from a file
into a Bitmap.

That''s what I''ve been looking for.
Thanks

"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...

The System.Drawing.Bitmap object is a DIB. If you want a DDB, use
GetHbitmap. If you want to construct a Bitmap from an existing DIB
created with CreateDIBSection or a GDI DDB handle, use one of the
constructors of the Bitmap class.

Use the Graphics method DrawImage to display or convert to a different
PixelFormat.

If you want to work with the native GDI API, then use CreateBitmap to
create a DDB or use CreateDIBSection to create a DIB.

To convert one to the other, use BitBlt or any of the other GDI "BitBlt"
variations.

" active" <ac**********@a-znet.comwrote in message
news:uk**************@TK2MSFTNGP04.phx.gbl...

>I''ve been looking on the Internet for a way to convert a DIB to a Bitmap
without success.

Now I''m wondering if that is the approach I should be taking.

All I want to do is display the DIB or draw it into a Bitmap.

Is there a graphics method that can help?

thanks




What the clipboard produces is a MemoryStream.

You can construct a Bitmap object from a MemoryStream object as is. Use the
Bitmap constructor or method which uses a stream object as an argument.
" active" <ac**********@a-znet.comwrote in message
news:up**************@TK2MSFTNGP05.phx.gbl...

>I hate it when I don''t ask the question right.

I want to get a DIB from the clipboard.

What the clipboard produces is a MemoryStream.

I have read that stream and obtained the palette in the DIB.

Now I''d like to get the bitmap which I think is harder to read from the
stream because there are so many variations.

I suppose at this point it is the same as reading the bitmap from a file
into a Bitmap.

That''s what I''ve been looking for.
Thanks

"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...

>The System.Drawing.Bitmap object is a DIB. If you want a DDB, use
GetHbitmap. If you want to construct a Bitmap from an existing DIB
created with CreateDIBSection or a GDI DDB handle, use one of the
constructors of the Bitmap class.

Use the Graphics method DrawImage to display or convert to a different
PixelFormat.

If you want to work with the native GDI API, then use CreateBitmap to
create a DDB or use CreateDIBSection to create a DIB.

To convert one to the other, use BitBlt or any of the other GDI "BitBlt"
variations.

" active" <ac**********@a-znet.comwrote in message
news:uk**************@TK2MSFTNGP04.phx.gbl...

>>I''ve been looking on the Internet for a way to convert a DIB to a Bitmap
without success.

Now I''m wondering if that is the approach I should be taking.

All I want to do is display the DIB or draw it into a Bitmap.

Is there a graphics method that can help?

thanks





这篇关于如何显示DIB或将其绘制到位图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆