将图形图像保存到位图? [英] Save graphics image to bitmap?

查看:53
本文介绍了将图形图像保存到位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试保存web浏览器控件的图像。不是特定的

图像显示在页面上,而是显示

webbrowser。使用VS2005我想也许DrawToBitmap可以工作,

但是看起来webbrowser没有实现它。


所以我环顾四周然后发现这段代码:


Dim g As Graphics

g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0,0)),New

Point(0,0),wb1.Size)


应该将图像转换为图形对象。我无法弄清楚

是如何将其转换为我可以依赖的位图。这个:


dim b为Bitmap = g。


似乎不是正确的方法;至少没有任何作用。


有没有办法做到这一点,还是我错了?我可以使用

SnagIt甚至PrintScreen将其转储到剪贴板中,因此必须有一些方法来获取它。非常感谢任何帮助。

I''m trying to save the image of a webbrowser control. Not a particular
image being shown on the page, but rather the visible display of the
webbrowser. Using VS2005 I figured that maybe DrawToBitmap would work,
but it appears that the webbrowser doesn''t implement it.

So I looked around and found that this code:

Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0, 0)), New
Point(0, 0), wb1.Size)

should get the image into a graphics object. What I can''t figure out
is how to get that into a bitmap that I can hang on to. This:

dim b as Bitmap = g.???

doesn''t appear to be the correct approach; at least nothing works.

Is there some way to do this or am I going about it wrong? I can use
SnagIt or even PrintScreen to dump it into the clipboard so there must
be some way to get at it. Any help greatly appreciated.

推荐答案

dgk,


网页中的图像(因此也是如此) webbrowser)必须永远

图像(或Java,Flash程序或任何与Web相关的)作为网址。


因此使用位图没有任何意义的网页浏览器。


你必须将图片(网址)设置为浏览器中的绝对位置或

创建第一个表格作为表格将它固定在它的位置。


我希望这会有所帮助,


Cor


" ; DGK" <否***** @ MailsAnonymous.com> schreef在bericht

新闻:9e ******************************** @ 4ax.com ...
dgk,

A image in a webpage (therefore as well in the webbrowser) has to be forever
an image (or Java, Flash program or whatever related for web) as an url.

Therefore working with bitmaps in a webbrowser is withouth any sense.

You have to set the picture (url) too an absolute place in the browser or
create first something as a table to fix it on its place.

I hope this helps,

Cor

"dgk" <No*****@MailsAnonymous.com> schreef in bericht
news:9e********************************@4ax.com...
我正在尝试保存webbrowser控件的图像。页面上没有显示特定的图像,而是
webbrowser的可见显示。使用VS2005我想也许DrawToBitmap可以工作,
但似乎webbrowser没有实现它。

所以我环顾四周,发现这段代码:

Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0,0)),New
Point(0,0),wb1.Size)

应该将图像转换为图形对象。我无法弄清楚
是如何将它变成我可以依赖的位图。这个:

dim b as Bitmap = g。???

似乎不是正确的方法;至少没有任何作用。

有没有办法做到这一点,还是我错了?我可以使用SnagIt甚至PrintScreen将其转储到剪贴板中,因此必须有一些方法来实现它。非常感谢任何帮助。
I''m trying to save the image of a webbrowser control. Not a particular
image being shown on the page, but rather the visible display of the
webbrowser. Using VS2005 I figured that maybe DrawToBitmap would work,
but it appears that the webbrowser doesn''t implement it.

So I looked around and found that this code:

Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0, 0)), New
Point(0, 0), wb1.Size)

should get the image into a graphics object. What I can''t figure out
is how to get that into a bitmap that I can hang on to. This:

dim b as Bitmap = g.???

doesn''t appear to be the correct approach; at least nothing works.

Is there some way to do this or am I going about it wrong? I can use
SnagIt or even PrintScreen to dump it into the clipboard so there must
be some way to get at it. Any help greatly appreciated.






将webbrowser控件停靠在面板中。使用面板drawtobitmap

方法。


Dim bmWb作为新位图(Panel1.Width,Panel1.Height)

Panel1。 DrawToBitmap(bmWb,Panel1.ClientRectangle)


PictureBox2.Image = bmWb

Ken

-------- -----------

" dgk" <否***** @ MailsAnonymous.com>在消息中写道

news:9e ******************************** @ 4ax.com ...
Hi,

Dock the webbrowser control in a panel. Use the panels drawtobitmap
method.

Dim bmWb As New Bitmap(Panel1.Width, Panel1.Height)
Panel1.DrawToBitmap(bmWb, Panel1.ClientRectangle)

PictureBox2.Image = bmWb
Ken
-------------------
"dgk" <No*****@MailsAnonymous.com> wrote in message
news:9e********************************@4ax.com...
我正在尝试保存webbrowser控件的图像。页面上没有显示特定的图像,而是
webbrowser的可见显示。使用VS2005我想也许DrawToBitmap可以工作,
但似乎webbrowser没有实现它。

所以我环顾四周,发现这段代码:

Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0,0)),New
Point(0,0),wb1.Size)

应该将图像转换为图形对象。我无法弄清楚
是如何将它变成我可以依赖的位图。这个:

dim b as Bitmap = g。???

似乎不是正确的方法;至少没有任何作用。

有没有办法做到这一点,还是我错了?我可以使用SnagIt甚至PrintScreen将其转储到剪贴板中,因此必须有一些方法来实现它。非常感谢任何帮助。
I''m trying to save the image of a webbrowser control. Not a particular
image being shown on the page, but rather the visible display of the
webbrowser. Using VS2005 I figured that maybe DrawToBitmap would work,
but it appears that the webbrowser doesn''t implement it.

So I looked around and found that this code:

Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0, 0)), New
Point(0, 0), wb1.Size)

should get the image into a graphics object. What I can''t figure out
is how to get that into a bitmap that I can hang on to. This:

dim b as Bitmap = g.???

doesn''t appear to be the correct approach; at least nothing works.

Is there some way to do this or am I going about it wrong? I can use
SnagIt or even PrintScreen to dump it into the clipboard so there must
be some way to get at it. Any help greatly appreciated.



2006年4月8日星期六06:40:07 -0400,Ken Tucker [MVP]
< vb *** @ bellsouth.net>写道:
On Sat, 8 Apr 2006 06:40:07 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote:


将webbrowser控件停靠在面板中。使用面板drawtobitmap
方法。

Dim bmWb作为新位图(Panel1.Width,Panel1.Height)
Panel1.DrawToBitmap(bmWb,Panel1.ClientRectangle)

PictureBox2.Image = bmWb

Hi,

Dock the webbrowser control in a panel. Use the panels drawtobitmap
method.

Dim bmWb As New Bitmap(Panel1.Width, Panel1.Height)
Panel1.DrawToBitmap(bmWb, Panel1.ClientRectangle)

PictureBox2.Image = bmWb
Ken




这很聪明但不起作用;我得到的只是一个白色的屏幕。我接下来试图摆脱面板并使用表单,但我得到了

整个表单,其中有一个很大的空白区域,其中有webbrowser。我想

这就是为什么我直接做这么多麻烦的原因;

webbrowser图像超出了项目的范围。


看来这不会是微不足道的。还有其他想法吗?



That was clever but it doesn''t work; all I get is a white screen. I
then tried getting rid of the panel and using the form, but I get the
whole form with a big white space where the webbrowser is. I guess
that''s why I was having so much trouble doing it straight; the
webbrowser image is sort of outside the scope of the project.

It appears that this is not going to be trivial. Any other ideas?


这篇关于将图形图像保存到位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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