-
March 7th, 2005, 12:57 PM
#1
HTML to BMP in VB.NET
I need to save an HTML file as a BMP. I've been able to to a "screen capture" and get a BMP that way, but what is not visible on the screen at the time is not saved. Is there a way to capture the entire HTML page in VB.NET and save it as an image?
Thanks in advance
-
March 10th, 2005, 01:50 PM
#2
Re: HTML to BMP in VB.NET
I'm actually replying to my own post in hopes of generating a possible solution. Here is the code I have thus far...
Dim doc As mshtml.HTMLDocument = DirectCast(Me.AxWebBrowser1.Document, mshtml.HTMLDocument)
Dim bodyElement As mshtml.IHTMLElement
Dim render2 As IHTMLElementRender
bodyElement = doc.body
render2 = bodyElement
Dim BitMap AsNew Bitmap(600, 400)
Dim g As Graphics = Graphics.FromImage(BitMap)
Dim memDC As IntPtr
Dim CCBHandle As IntPtr
Dim memDC2 As mshtml._RemotableHandle
Dim tt AsInteger
memDC = g.GetHdc()
Try
render2.DrawToDC(memDC)
Catch ex As Exception
MsgBox(ex.ToString)
EndTry
Try
BitMap.FromHbitmap(memDC)
Catch exc As Exception
MsgBox(Err.Description)
MsgBox(exc.ToString)
EndTry
BitMap.Save("c:\newread\test.tif", System.Drawing.Imaging.ImageFormat.Tiff)
MsgBox("Image created!")
I don't get an error on my DrawToDC() function, so I feel like I've rendered my HTML page to the Device Context in memory, but by golly I'm not entirely sure.
Does anyone have further insight in this matter; how to insert what I've rendered into a bitmap? Any thoughts would be helpful.
Thanks much
"Go back to the shadow. You shall not pass."
-
May 2nd, 2005, 10:23 AM
#3
Re: HTML to BMP in VB.NET
Trouble in Rivercity...still need solution!
-
May 2nd, 2005, 11:33 AM
#4
Re: HTML to BMP in VB.NET
You can use BitBlt to copy from on hDC to another:
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Private Const SRCCOPY = &HCC0020
Pass SRCCOPY as teh dwRop Parameter.
-
May 2nd, 2005, 02:22 PM
#5
Re: HTML to BMP in VB.NET
How??? You'll have to spell it out for me as if I was a first grader, cuz right now my brain is about fried trying to figure this doggone thing out.
-
May 2nd, 2005, 03:25 PM
#6
Re: HTML to BMP in VB.NET
Actually, after having reviewed your code again, you're already putting it into the bitmaps hDC, so all you should need is:
Dim doc As mshtml.HTMLDocument = DirectCast(Me.AxWebBrowser1.Document, mshtml.HTMLDocument)
Dim bodyElement As mshtml.IHTMLElement
Dim render2 As IHTMLElementRender
bodyElement = doc.body
render2 = bodyElement
Dim BitMap AsNew Bitmap(600, 400)
Dim g As Graphics = Graphics.FromImage(BitMap)
memDC = g.GetHdc()
Try
render2.DrawToDC(memDC)
Catch ex As Exception
MsgBox(ex.ToString)
EndTry
BitMap.Save("c:\newread\test.tif", System.Drawing.Imaging.ImageFormat.Tiff)
MsgBox("Image created!")
I don't us those browser controls, so I'm assuming DrawToDC is doing what we think it is.
-
April 14th, 2013, 10:29 PM
#7
Re: HTML to BMP in VB.NET
i like the idea of saving html to an image , that's because i just in love with a new image converter.
-
April 16th, 2013, 10:49 AM
#8
Re: HTML to BMP in VB.NET
This thread is 6 Years old! really....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|