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. Image for the cookie policy date
close icon

Image loaded from a resource file

Has anyone been able to load an image from a resource file into an htmlui control? I have not seen an example of this and can only figure out how to pull an image off of a windows directory. This would be useful because resource files make the entire application more portable. Any comments would be appreciated.

4 Replies

NR Nandakumar R Syncfusion Team March 13, 2006 01:17 PM UTC

Hi Neil, Thanks for the feedback. Loading an image file from a resource in to an HTMLUI control will be a good feature to have. I will put in a feature request to enable methods to load images from stream in to the HTMLUI control to our developers. HTMLUI control supports using custom controls into the htmlui control. Please refer the sample attached. The html file contains an image tag with the ''ImageFromStream'' attribute. At run time the sample replaces a PictureBox for the image tag and renders the embedded image from the stream. Hope this helps. Thanks for your interest in EssentialHTMLUI. Regards, Nanda.

LoadImageFromResource_41794.zip


NC Neil Conway March 16, 2006 01:28 AM UTC

Thank you for taking the time to create that example, Nanda. It was very informative. That will serve as a good workaround. Regards, Neil Conway


AD Administrator Syncfusion Team July 4, 2006 09:50 AM UTC

Hi, in the version 3.0.1 it was possible to connect to the NoImage-event of the img-elements in the PreRenderDocument event. If the src-attribute targeted a non existing file, the NoIMage-event was fired and you could supply a stream (e.g. from a resource) and a key to make the control render the image. Unfortunately this does no longer work in 4.2. Perhaps this helps Regards rainer BTW: is it possible to reactive the behaviour from 3.0.1?


NR Nandakumar R Syncfusion Team July 5, 2006 11:52 PM UTC

Hi Rainer, Thank you for your interest in Essential HTMLUI. In the 4.2.0.37 version of Syncfusion Essential Studio, we can easily load an image in the HTMLUI control from stream to the IMGElementImpl object. Please refer the following code snippet. [C#] using System.IO; using Syncfusion.Windows.Forms.HTMLUI; Assembly assembly = Assembly.GetExecutingAssembly(); Stream imageStream = assembly.GetManifestResourceStream("LoadImageFromResource.image.bmp"); IMGElementImpl img = this.htmluiControl1.Document.GetElementByUserId("img") as IMGElementImpl; img.Image = Image.FromStream(imageStream) as Bitmap; //The previous line can be replaced with the following commented statement. //img.Image = Syncfusion.HTMLUI.Base.Utility.Utilities.ImageFromStream(imageStream); Please refer the attached sample that uses the above mentioned steps to load an image from the stream in the HTMLUI control. I have requested our developers to look in to the NoImage event failure. I will get back to you with the suggested fix at the earliest. Thank you for your extensive feedback. Regards, Nanda ImageFromStream.zip

Loader.
Live Chat Icon For mobile
Up arrow icon