Loading of Memorystream C#

Asked

Viewed 129 times

0

How do I load a document over 4069 kb.

Example: I have a 14,000 kb document to click on MemoryStream that does not load because it is giving a memory exception! How can I load this file?

Excerpt from the code:

public ElementImage(string imageBase64, Size size, Point position, bool stretch)
    : base()
{
    this.imgBase64 = imageBase64;
    this.Size = size;
    this.Position = position;
    this.Stretch = stretch;

    byte[] imageData = Convert.FromBase64String(imageBase64);
    using (MemoryStream ms = new MemoryStream(imageData))
    {
        if (stretch)
            this.img = Image.FromStream(ms);
        else
        {
            Bitmap bmpImage = new Bitmap(Image.FromStream(ms));
            Bitmap bmpCrop = bmpImage.Clone(new Rectangle(this.Position.X, this.Position.Y, (int)this.Size.Width, (int)this.Size.Height), bmpImage.PixelFormat);
            this.img = (Image)(bmpCrop);
        }
    }    
} 
  • the shipment is done as? could put a code snippet where this takes place? What your goal is to make such a upload, you want to analyze the uploaded file or use your Iprs?

  • I load an xml into a Memorystream , which creates a print-preview xml document. Only it only loads up to 4069 kb! and need to upload around 2k pages for more.

  • it is feasible to divide this xml and to load it by parts in this visualization template for printing?

  • Puts snippets of code in the question to help exemplify the way the file is loading

  • I edited the post with a part of the code.

  • What is the exact message you are receiving about "memory exception?"?

  • The exception happens at bmpCrop, right? Try replacing the first two parameters with 0, if that’s not what you’re getting, because it might be out of the scope of the position values. Also, Ql is the pixelFormat value?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.