We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

HTMLUIControl.DrawToBitmap

I noticed a method on the control called DrawToBitmap. What does that do? How does it work? Will it draw to a bitmap any html I pass to it or just the whole control? I did notice it takes TargetBounds as one of it's parms. My interest is based on my need to create a drag image during mouse interactions. I could not find the link to the online doc for this method. Thanks.

- Randolph



3 Replies

VS Vallarasu S Syncfusion Team June 9, 2011 05:20 AM UTC

Hi Randolph,

Thanks for your interest in Syncfusion products.

Control.DrawToBitmap method is inherited from Control, which paints the control into a bitmap. you can later use this bitmap to drag or paint to the form.

Place this code in the paint event of a form hosting a HTMLUIControl, and comment the following code from the designer generated code, which remove the control form the Form.Controls collection.

//this.Controls.AddRange(new System.Windows.Forms.Control[] {this.htmluiControl1});

Now you can notice the bitmap being drawn to the form.


Bitmap bmp = new Bitmap(300, 300);

// Renders the HTMLUIControl to the bitmap.
this.htmluiControl1.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));

/* Similarly you can call this piece of code.*/
// Graphics g = Graphics.FromImage(bmp);
// PaintEventArgs arg = new PaintEventArgs(g, new Rectangle(Point.Empty, bmp.Size));
// this.htmluiControl1.Document.Draw(arg, Point.Empty);

// Paints the bitmap to the form.
e.Graphics.DrawImage(bmp, Point.Empty);

// We have a DragHelper, you can make use of to perform this drag drop with this bitmap.
// Syncfusion.Windows.Forms.DragHelper


Please let me know if you need any further assistance.

Regards
Vallarasu S.




RW Randolph Webb June 15, 2011 06:37 PM UTC

Hello Vallarasu,

Is there a function within the HTMLUI control that can return an image based on HTML I pass to it (with alpha channel ghosting/transparency)? Specifically, my use of the HTMLUI control is not to present the end user an interactive HTML document. My usage is just to paint the html of the underlying document. Given a click on the view presented to the end user, I need to be able to create an image of the control/area the user clicked on. I then intend to set that image as a cursor during a mousedown drag. It would be most ideal if there were a function to which I could pass some html and get back an image. Thanks,

- Randolph



VS Vallarasu S Syncfusion Team June 21, 2011 09:48 AM UTC

Hi Randolph,

Thanks for the update.

You can make use of HTMLUIControl.DrawToBitmap and HTMLUIControl.Document.Draw methods to render the content of the controls as an Image as in the code snippet in my previous update.

Let me know if you need any further assistance on this.

Regards
Vallarasu S.


Loader.
Live Chat Icon For mobile
Up arrow icon