Load Image from Stream

pinbotpinbot Texas
edited 11:28PM in FastReport .NET
Is there a way to load an image from a stream?

I can generate a URL that will thumbnail a photo on the fly.

In FR Studio I would do an OnBeforePrint and some WebClient C# to load into the image just before displaying.

IfrxPictureView pict = (IfrxPictureView)Sender;
...
pict.LoadViewFromStream(s);


That way the image was already resized before becoming part of the report.

In Fr.Net I see MyPicture.Image.Save which will take a stream but no corresponding MyPicture.Image.Load

Thanks,

Bryan

Comments

  • edited 11:28PM
    Hello,

    Here is an example how you can load an image from a file:
        private void Picture1_BeforePrint(object sender, EventArgs e)
        {
          Picture1.Image = new Bitmap(@"c:\test.png");
        }
    

    using another overloads of Bitmap constructor, you may load from stream.
  • pinbotpinbot Texas
    edited 11:28PM
    Actually it was even easier than that.

    I just set ImageLocation to be my full URL in the BeforePrint and FR.NET loaded the picture for me!


    private void PropertyPicture_BeforePrint(object sender, EventArgs e)
    {
    String URL;

    URL = "http://www.xxx.xxx/aptpicture/?"; + ((String)Report.GetColumnValue("PropSheetQuery.ApartmentPictureURL"));
    URL += "&h=" + ((int)PropertyPicture.Height).ToString();
    URL += "&w=" + ((int)PropertyPicture.Width).ToString();

    PropertyPicture.ImageLocation=URL;
    }



    >[img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> I do need that for another image though so thanks for the quick reply.[/img]
  • edited 11:28PM
    check the folloing C# image load codes,
    public static void LoadImageFromFileDemo()
    {
    string fileName = "c:/Sample.png";

    REImage reImage = REFile.OpenImageFile(fileName);

    }
  • edited May 2013
    yes , that method can make it happen for you
  • edited 11:28PM
    i think it is easy for us to do image file loading, but from loading image from stream or frum graphics.much difficult.
    most of us are simply using some software to do the job for us. but for programmer, we are searching for the most useful tool that can make things easier.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.