TX Text Control Blog

Embedding images in various formats

Blogged by Björn Meyer on April 6, 2005 and tagged with samples, image, .net.

We are frequently asked why the filesize of documents containing images (BMP and WMF) grows when they are exported to Microsoft Word or RTF formats.

The answer is quite simple:

Images might be exported as a BMP or WMF files, which are typically built from uncompressed data.

Reducing the filesize of documents containing images is equally simple:

TX Text Control .NET supports image export to external files, using compressed formats, such as JPG or PNG. Developers often are not aware that the image format can be also specified, if the images are embedded in the document itself.

The SaveMode property of the Image class specifies whether the image should be exported or embedded in the document.

The ExportFilterIndex, on the other hand, specifies the format of the image. Possible formats are: BMP, WMF, PNG or JPG.

In the following VB.NET sample, the resulting document size clearly demonstrates the effect of setting an appropriate image format:

BMP -> 151 KBWMF -> 53 KBPNG -> 56 KBJPG -> 13 KB

The sample shows how to change every image format in a document. The ComboBox receives all image formats from the Images.ExportFilters property.

For Each image As TXTextControl.Image In TextControl1.Images image.ExportFilterIndex = ComboBox1.SelectedIndex + 1 image.SaveMode = TXTextControl.ImageSaveMode.SaveAsData Next Dim fileFormatIndex As String = ComboBox1.SelectedIndex + 1 TextControl1.Save("test_" + fileFormatIndex + ".rtf", TXTextControl. StreamType.RichTextFormat)
 
 
User Contributed Note

User Contributed Note by Scotton April 11, 2005 at 10:25:35 PM CEST

Are you going to support inline image data anytime soon? Here's an example: http://scott.connerly.net/sideload/inline.html It works on Moz but not IE or TX Text Control right now.
User Contributed Note

User Contributed Note by Björn Meyer on April 12, 2005 at 3:07:04 PM CEST

Very interesting question. I am going to discuss this with our developer team.
User Contributed Note

User Contributed Note by Scotton September 23, 2005 at 7:57:44 AM CEST

Any thoughts yet on supporting this? I know the company that I work for (that already subscribes to TX) would have great use for it. I would restrain from identifying my company, as this is not an 'official' posting...
User Contributed Note

User Contributed Note by Björn Meyer on September 23, 2005 at 9:51:35 AM CEST

I discussed this feature with our HTML filter specialists. We are going to consider that with special regard to the new trojans and viruses in JPG images. IMHO, this is a very sensitive way to include images in an HTML document.
User Contributed Note

User Contributed Note by Scotton September 28, 2005 at 6:41:06 PM CEST

In case you wanted the RFC's on this protocol, here you go: http://www.ietf.org/rfc/rfc2557.txt http://www.faqs.org/rfcs/rfc2397.html Thank you for considering including this.
User Contributed Note

User Contributed Note by Sabrinaon January 22, 2008 at 3:07:19 PM CET

Question, maybe silly for you but why in any place of the documentation of your control there is not a list of the ExportFilterIndex values and their meaning? I've found a thread on an error and in that thread such as in this post it is indicated that the above property can be used to avoid problems. Now I've found it can be set to 3 but what means 3 BMP?JPG?WMF?PNG?TIF? In the documentation in the CHM and also in the online documentation the property is described but there is not a reference table. This property as many others in your control is an integer, why not use an Enum??? Sorry but I'm a little bit frustrated because I'm not able to save and reload a document with images from your control and I have a demo tomorrow morning, if you can let know to the people who writes the documentation that the admissible values for the enumerated properties would be a helpful addin to the property definition it would be very kind. Sabrina
User Contributed Note

User Contributed Note by Igal Foigel on May 16, 2009 at 5:27:44 PM CEST

Hey, I've noticed Scott's question from Apr 2005 regarding inline image data for HTML format. My company is in the process of finding a solution like TX Text Control offers and this feature - inline image data for HTML format - stands as a central requirement. Is this feature included in the latest TX Text Control .NET for WinForms? If not - can we expect it in the near future? Thanks, Igal
User Contributed Note

User Contributed Note by Björn Meyer on May 18, 2009 at 9:21:48 AM CEST

Hello Quick note: TX Text Control 15.0 now supports embedded images in HTML in all versions.