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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

RichTextBox - Sending "zoomed" output to bitmap

Thread ID:





38329 Dec 9,2005 05:35 PM UTC Dec 13,2005 04:47 PM UTC WinForms 1
Tags: Diagram
Lori S. Pearsall
Asked On December 9, 2005 05:35 PM UTC

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 04:47 PM UTC

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.,


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon