Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
How to add image to formatted text at runtime?
posted

I want to add an image to a formatted text editor at runtime. The image is will be stored in a dataset as "image" type. I don't want to write the image locally and reference it, I would like to do it all in memory. I know the formatted text editor can save an image as XML data and see how it serializes it...but I need some help on doing that myself.

 Here is my thought. If I have some formatted text that looks like this I can just to a replace string and add my image to it:

str = <img style="width:16px; height:16px;" data="%MYIMAGE%"/>

str.Replace("%MYIMAGE%",newImageData)

I don't know how to get the newImageData. Do I just serialize the byte array of the image cell to a string and add that?

Thanks - Michael

 

 

  • 469350
    Verified Answer
    Offline posted
    The FormattedLinkEditor class has a static method called EncodeImage which takes an image instance and returns a strings which you can use in the data tag.