MarkupLabel - capture image |
Post Reply |
Author | |
chrisABC
Senior Member Joined: 05 June 2008 Status: Offline Points: 258 |
Post Options
Thanks(0)
Posted: 06 September 2009 at 8:02pm |
Using the MarkupLabel control you can create an image on the label from XAML, for example a Chart.
Here is some VB code that allows you to capture this image, with examples showing how to copy it to the Clipboard, Save to disk as a BMP, or Print to printer. It uses API calls, and stores the captured image in a PictureBox (which is not visible). There may be easier or better ways to do this, but this seems to work fine. You need a Form with a MarkupLabel on it. Add three Command Buttons and a PictureBox. There is just one Function, and some Declarations (uploads/20090906_195728_CaptureMarkupLa.zip). And the following in the Button Click events: Private Sub cmdCopy_Click() Set Picture1.Picture = CaptureMarkupToPicturebox Clipboard.Clear ' Clear Clipboard. Clipboard.SetData Picture1.Image, vbCFBitmap End Sub Private Sub cmdPrint_Click() Set Picture1.Picture = CaptureMarkupToPicturebox Printer.PaintPicture Picture1.Image, 100, 100 ', p.Width * Resize, p.Height * Resize Printer.EndDoc End Sub Private Sub cmdSave_Click() Set Picture1.Picture = CaptureMarkupToPicturebox SavePicture Picture1.Picture, "C:\mychart.bmp" End Sub Also set the PictureBox properties (eg in Form_Load) Picture1.AutoSize = True Picture1.Visible = False I added this code to the excellent XamlCharts sample (which you can download from this Forum). Now I can Print, Copy, or Save the resulting Chart images. |
|
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Cool, nice work Chris! Thanks for this.
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
Andrew666
Groupie Joined: 15 October 2008 Status: Offline Points: 27 |
Post Options
Thanks(0)
|
This works fine if the XAML is fully visible - but if it is partially or totally hidden (e.g. if the containing form is not visible) then it won't work, as it depends on BitBlt. Putting it in a PrintPreview control doesn't work either, as you can't do anything but print from that control.
It would be great if there was a "copy" method for the XAML markup label or access to a picture object...
--Andrew
|
|
drimage
Newbie Joined: 05 June 2013 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
the following are some codes about how to capture images in vb.
Public Function TwainAcquireToRasterEdgeImageImage(ByVal HANDLE As Integer) As Integer |
|
arronlee
Newbie Joined: 04 September 2013 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Hi, thanks for your sharing. Becayse I am not so familiar with VB.NET processing, I focus more on capturing images using Twain Scanning in C#.NET. Can you offer some more tutorials about that?Thanks in advance. Best regards, Arron |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |