Version

DecodeImage Method (FormattedTextEditInfo)

Decodes the specified image data that was encoded using EncodeImage into an image.
Syntax
'Declaration
 
Public Function DecodeImage( _
   ByVal imageData As String _
) As Image
public Image DecodeImage( 
   string imageData
)

Parameters

imageData
The string returned by a call to EncodeImage.

Return Value

Remarks
See EncodeImage for more information.
Example
The following code shows you how to insert images in formatted text. Note that the following code example relies upon test.bmp image file being in the current path. Also note that it is not necessary to use InsertValue method to include images in formatted text. You can directly construct an entire formatted text value that contains the necessary 'img' tags and set the Value property of the editor to that value.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc
Imports Infragistics.Win.FormattedLinkLabel

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
        Dim editInfo As FormattedTextEditInfo = Me.UltraFormattedTextEditor1.EditInfo

        editInfo.SelectionStart = 0
        editInfo.SelectionLength = 0

        Dim imagePath As String = "test.bmp"

        ' Insert an image using 'src' attribute. The formatted text value doesn't actually
        ' contain the image data. It stores an URL from which it retrieves the image.
        ' This means that the image must exist at the specified path when the application
        ' is run. Note that you can specify BaseURL property to specify relative paths
        ' for images.
        editInfo.InsertValue("Referenced Image: <br/> <img src=""" & imagePath + """ width=""50"" height=""50"" /> <br/>")

        ' Create an Image instance from the file.
        Dim img As Image = Image.FromFile(imagePath)

        ' Encode it into a string that's suitable for embedding in the formatted text. 
        ' Use the EncodeImage method to accomplish that.
        Dim imgAsEncodedString As String = editInfo.EncodeImage(img)

        ' Insert the image with image data embedded inside the formated text. Notice the
        ' 'data' attribute of 'img' tag. To specify embedded image data, you use the 'data'
        ' attribute instead of te 'src' attribute.
        editInfo.InsertValue("Embedded Image: <br/> <img data=""" & imgAsEncodedString + """ width=""50"" height=""50"" /> <br/>")

        ' Print out the formatted text value. Notice the embedded image data in the output.
        Debug.WriteLine("Formatted Text: " & Me.UltraFormattedTextEditor1.Value.ToString())

        ' You can use the DecodeImage to decode an image that was encoded using EncodeImage
        ' method.
        Dim decodedImage As Image = editInfo.DecodeImage(imgAsEncodedString)
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Misc;
using Infragistics.Win.FormattedLinkLabel;
using System.Diagnostics;


		private void button1_Click(object sender, System.EventArgs e)
		{
			FormattedTextEditInfo editInfo = this.ultraFormattedTextEditor1.EditInfo;

			editInfo.SelectionStart = 0;
			editInfo.SelectionLength = 0;

			string imagePath = "test.bmp";

			// Insert an image using 'src' attribute. The formatted text value doesn't actually
			// contain the image data. It stores an URL from which it retrieves the image.
			// This means that the image must exist at the specified path when the application
			// is run. Note that you can specify BaseURL property to specify relative paths
			// for images.
			editInfo.InsertValue( @"Referenced Image: <br/> <img src=""" + imagePath + @""" width=""50"" height=""50"" /> <br/>" );

			// Create an Image instance from the file.
			Image img = Image.FromFile( imagePath );

			// Encode it into a string that's suitable for embedding in the formatted text. 
			// Use the EncodeImage method to accomplish that.
			string imgAsEncodedString = editInfo.EncodeImage( img );

			// Insert the image with image data embedded inside the formated text. Notice the
			// 'data' attribute of 'img' tag. To specify embedded image data, you use the 'data'
			// attribute instead of te 'src' attribute.
			editInfo.InsertValue( @"Embedded Image: <br/> <img data=""" + imgAsEncodedString + @""" width=""50"" height=""50"" /> <br/>" );

			// Print out the formatted text value. Notice the embedded image data in the output.
			Debug.WriteLine( "Formatted Text: " + this.ultraFormattedTextEditor1.Value.ToString( ) );

			// You can use the DecodeImage to decode an image that was encoded using EncodeImage
			// method.
			Image decodedImage = editInfo.DecodeImage( imgAsEncodedString );
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also