Hi there,
I would like to display thousands of image files on the screen. I am using the following code to display them:
Bitmap Origbmp = new Bitmap(Filename);
bmp = new Bitmap(Origbmp.Width, Origbmp.Height, PixelFormat.Format32bppArgb);
Graphics gr = Graphics.FromImage(bmp);
gr.DrawImage(Origbmp, 0, 0, Origbmp.Width, Origbmp.Height);
but now the files are in a special format that cannot be displayed using the above code. So I have to load the file into memory, change some particular bytes and then pass them to the Origbmp. so I do as follows:
//read the file into a stream
byte[] fileInBytes = File.ReadAllBytes(Filename);
Stream fileInStream = new MemoryStream(fileInBytes);
fileInStream.Write(Newbytes, pos,len);
Bitmap Origbmp = new Bitmap(fileInStream);
bmp = new Bitmap(Origbmp.Width, Origbmp.Height, PixelFormat.Format32bppArgb);
Graphics gr = Graphics.FromImage(bmp);
gr.DrawImage(Origbmp, 0, 0, Origbmp.Width, Origbmp.Height);
is there anyway to do it faster? How can I read the file directly to a stream rather than first reading it to a byte array and then to a stream?
Is there any other way to do the whole thing more efficient and faster?