Now I am trying to get a Image Class from jpg Image. I already tried to use BitmapSource linked at here.
The error is not english, but the meaning is "the image header is broken. so, it is impossible to decode.". The other formats like gif, png, bmp has no problem. only jpg format faced on this problem.
< Sequence > An Zip Archive file(jpg file is in this file.) -> unzip library -> MemoryStream(jpg file) -> BitmapSource
imageSource.BeginInit();
imageSource.StreamSource = memoryStream;
imageSource.EndInit();
this code makes the error.
I think the reason is the memory stream has raw binary of jpg, and it is not Bitmap format. So, BitmapSource cannot recognize this memory stream data as a bitmap image.
How can I solve this problem? My goal is that Input : "ZIP File(in jpg)" -> Output : Image Class.
Thank you!
< My Code >
using (MemoryStream _reader = new MemoryStream())
{
reader.WriteEntryTo(_reader); // <- input jpg_data to _reader
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.StreamSource = _reader;
bitmap.EndInit();
bitmap.Freeze();
Image tmpImg = new Image();
tmpImg.Source = bitmap;
}