I want to display very large Image (36000 x 36000) So i tried use mat to load a very large image after make submat I used Mat made of SubMat as the Source of Image to be printed, but the image was not printed.
public BitmapImage[] loadBitmap(string fullpath)
{
BitmapImage[] bitmap=new BitmapImage[4];
using (var mat = Cv2.ImRead(fullpath, ImreadModes.Color))
{
for (int i = 0; i < bitmap.Count(); i++)
{
//System.Windows.Controls.Image image = new System.Windows.Controls.Image();
Mat submat= mat.SubMat(new OpenCvSharp.Rect(mat.Width / 2 * (i / 2), mat.Height / 2 * (i % 2), mat.Width / 2, mat.Height / 2));
Bitmap bit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(submat);
originImageWidth = mat.Width;
originImageHeight = mat.Height;
using (MemoryStream outstream = new MemoryStream())
{
BitmapImage _bitmap = new BitmapImage();
bit.Save(outstream, System.Drawing.Imaging.ImageFormat.Jpeg);
bit.Dispose();
outstream.Position = 0;
_bitmap.BeginInit();
_bitmap.StreamSource = outstream;
_bitmap.CacheOption = BitmapCacheOption.OnLoad;
_bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
_bitmap.EndInit();
bitmap[i] = _bitmap;
}
}
}
}
public System.Windows.Controls.Image[] image;
public void print()
{
BitmapImage[] bitmaparray = loadBitmap(fullpath);
image = new System.Windows.Controls.Image[4];
for(int i=0;i<bitmaparray.Count();i++)
{
image[i].source = bitmaparray[i]; // << here image[i].pixelHeight,pixelWidth ==0 and image.Uri is null
Canvas.SetLeft(image[i],bitmaparray[i].Width*(i%2));
Canvas.SetTop(image[i],bitmaparray[i].Height*(i/2));
canvas.Children.Add(image[i]); // not printed this canvas
}
}