Reading images from a zip with Ziplib -
12-22-2007
, 11:40 AM
Hi there,
I have a bunch of images stored in a zipfile that is stored on the device.
I'm trying to read the image out of the zip like this:
try
{
ZipFile zFile = new ZipFile(zipname);
ZipEntry currentEntry = zFile.GetEntry(filename);
if (currentEntry.Name != null)
{
Stream ImgInputStream = zFile.GetInputStream(currentEntry);
byte[] RawImage = new byte[currentEntry.Size];
ImgInputStream.Read(RawImage, 0,
Convert.ToInt32(currentEntry.Size));
MemoryStream MStream = new MemoryStream(RawImage);
animCtl.Bitmap = new Bitmap(MStream);
ImgInputStream.Close();
MStream.Close();
}
zFile.Close();
etc.
Now the operation completes successfully, however part of the image is
completely garbled and I have no clue why. I have some feeling that it
has something to do with the size of the image; small images can be read
easily, the bigger the image is there are problems.
I'm reading the Inputstream in one chunk, probably the memory card can't
deliver so fast and there are timouts or something.
Is there any simple way to deal with such timeouts? Or could the problem
result because of other reasons?
Thanks in advance,
Dominik |