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.For mat32bppArgb);
Graphics gr = Graphics.FromIm age(bmp);
gr.DrawImage(Or igbmp, 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.ReadAllByt es(Filename);
Stream fileInStream = new MemoryStream(fi leInBytes);
fileInStream.Wr ite(Newbytes, pos,len);
Bitmap Origbmp = new Bitmap(fileInSt ream);
bmp = new Bitmap(Origbmp. Width, Origbmp.Height, PixelFormat.For mat32bppArgb);
Graphics gr = Graphics.FromIm age(bmp);
gr.DrawImage(Or igbmp, 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?
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.For mat32bppArgb);
Graphics gr = Graphics.FromIm age(bmp);
gr.DrawImage(Or igbmp, 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.ReadAllByt es(Filename);
Stream fileInStream = new MemoryStream(fi leInBytes);
fileInStream.Wr ite(Newbytes, pos,len);
Bitmap Origbmp = new Bitmap(fileInSt ream);
bmp = new Bitmap(Origbmp. Width, Origbmp.Height, PixelFormat.For mat32bppArgb);
Graphics gr = Graphics.FromIm age(bmp);
gr.DrawImage(Or igbmp, 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?
Comment