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.
Unfortunately, activation email could not send to your email. Please try again.

RichTextBox - Sending "zoomed" output to bitmap

Thread ID:

Created:

Updated:

Platform:

Replies:

38329 Dec 9,2005 12:35 PM Dec 13,2005 11:47 AM Windows Forms 1
loading
Tags: Diagram
Lori S. Pearsall
Asked On December 9, 2005 12:35 PM

This question is of a somewhat general nature, but I thought this group would most likely to have an answer. I have code that allows me to basically write the contents of a richtextbox to a bitmap (sending a EM_FORMATRANGE using SendMessage). This code works fine, but it always draws the text "normal size" regardless of the setting of ZoomFactor in the RichTextBox. How can I get the "zoomed" version of the text into a bitmap? Thanks in advance!

Administrator [Syncfusion]
Replied On December 13, 2005 11:47 AM

Hi Lori, Essential Diagram uses a similar approach for drawing its RichTextNode object. To achieve a zoomed effect on the rendered text, we apply a scaling transformation to the destination Graphics object, render the contents of the RichText to a separate bitmap graphics object and then use Graphics.DrawImage to copy the contents of the text bitmap onto the destination Graphics. The following outline should give you an idea about the approach that we use, // grfx is the destination graphics object // Apply a scaling transformation to the Graphics // using the zoom scale // For a 200% zoom Matrix zoomMtrx = new Matrix(2,0,0,2,0,0); grfx.Transform = zoomMtrx; // Create a bmp Graphics for the RichText control System.Drawing.Rectangle txtbounds; Bitmap textimage = new Bitmap(txtbounds.Width, txtbounds.Height); Graphics bmpgrfx = Graphics.FromImage(textimage); // Draw the RichText contents this.DrawRichText(bmpgrfx, this.richTextCtl.Rtf, false, txtbounds, txtbounds, this.BackgroundColor, System.Drawing.Rectangle.Empty, true, 100); bmpgrfx.Dispose(); // Now copy the contents of the text image onto the destination graphics object PointF[] destPoints; grfx.DrawImage( textimage, destPoints, new RectangleF( 0, 0, textimage.Width, textimage.Height), GraphicsUnit.Pixel, imgAttr ); textimage.Dispose(); grfx.ResetTransform(); grfx.Dispose() Hope this helps. Prakash Surendra Syncfusion Inc.,

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;