This message contains graphics. If you do not see the graphics: Graphic Version.
Exporting Images in TXv10, New site features

Exporting Images in TX Text Control v10

One of the new features of TX Text Control v10 is the image export. The format of the exported images and whether the image files should be saved inline or to separate files can be set programmatically or by the end-user. Saving to separate files is ideally suited for applications that rely on HTML.

This brief code snippet illustrates how the new export features can be used. Our finished application looks like this:

Download the source code below and start the sample application. Click on the menu "Image -> Insert", browse for an image of your choice and click on "Open". Note here that all supported images are displayed. It is not necessary to select JPGs or PNGs explicitly. We will be discussing more on this later.

The image is then inserted. Activate the image by clicking on it. Then go to the image menu and select "Image Settings". A dialog box will open and you will be able to set the export properties of the image. The image is embedded as default and saved in TX Text Control's internal format.

Here is the code that enables the dialog settings:

Private Sub Form_Activate() optEmbed.Value = (Form1.TXTextControl1.ImageSaveMode = 1) optExport.Value = (Form1.TXTextControl1.ImageSaveMode = 0) If (Form1.TXTextControl1.ImageExportFormat > 0) Then cboFileFormats.ListIndex = Form1.TXTextControl1.ImageExportFormat - 1 End If End Sub

Using the ImageSaveMode property, we can determine whether the image is saved to a new file or be embedded. Using ImageExportFormat, we can determine the current format. This is an index to the combo box items of image types that is created when the program starts. Following is the code to do this:

Private Sub Form_Load() ' Fill combo box with available image file formats Dim FileFormats As String FileFormats = Form1.TXTextControl1.ImageExportFilters While Len(FileFormats) n = InStr(FileFormats, "|") ' find first occurence of "|" character n = InStr(n + 1, FileFormats, "|") ' find second occurence of "|" character If n Then cboFileFormats.AddItem Left(FileFormats, n - 1) FileFormats = Right(FileFormats, Len(FileFormats) - n) Else cboFileFormats.AddItem FileFormats FileFormats = "" End If Wend End Sub

The ImageExportFilters method returns a string that holds the installed export filter formats, formatted for a common dialog that we can apply to the "Filter" parameter.

Now we need to parse the string to get the actual formats. These are stored in the combo box.

Similarly, we build up a string called sExportFilters as mentioned above that holds all formats separated by a semicolon in the "Load" routine of Form1. This string can be applied to the "Filter" parameter of a common dialog and thus all supported formats are displayed at once. Here is the code:

Private Sub Form_Load() Dim nPos As Integer Dim nLength As Integer Dim sTemp As String sTemp = TXTextControl1.ImageExportFilters While (Len(sTemp) <> 0) nPos = InStr(1, sTemp, "|") If (Len(sExportFilters) <> 0) Then sExportFilters = sExportFilters + ";" sExportFilters = sExportFilters + Mid(sTemp, nPos + 1, 5) sTemp = Mid(sTemp, nPos + 7) Wend End Sub

As ever, we would be delighted to help you with this example. Please post your questions and requests for support into the TX Text Control Support Forum.

Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2020 Text Control GmbH. All Rights Reserved.