How do I load a document over 4069 kb.
Example: I have a 14,000 kb document to load into MemoryStream
that does not load because it is giving a memory exception! How can I load this file?
Code snippet:
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);
}
}
}