Ejemplo n.º 1
0
        private void AddMutliframedImageToCanvas(ImageMatrix imageMtx, ref int i, ref int j, int frames)
        {
            for (int frameIndex = 0; frameIndex < frames; frameIndex++, j++)
            {
                if (j >= Columns)
                {
                    j = 0;
                    i++;
                }

                Console.Out.WriteLine("Adding new MF image at Row: " + i + " Column: " + j);
                System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                var img = imageMtx.GetImage(frameIndex);
                ImageConverter imgConv = new ImageConverter();

                var bytes = (byte[])imgConv.ConvertTo(img, typeof(byte[]));
                MemoryStream ms = new MemoryStream(bytes);
                BitmapImage bmpImg = new BitmapImage();
                bmpImg.BeginInit();
                bmpImg.StreamSource = ms;
                bmpImg.EndInit();
                image.Source = bmpImg;
                image.Width = image.Width * ScaledWidth;
                image.Height = image.Height * ScaledHeight;

                Grid.SetRow(image, i);
                Grid.SetColumn(image, j);
                CanvasGrid.Children.Add(image);
            }
        }
Ejemplo n.º 2
0
        private void AddSingleFrameImageToCanvas(ImageMatrix imageMtx, ref int i, ref int j)
        {
            Console.Out.WriteLine("Adding new SF image at Row: " + i + " Column: " + j);
            System.Windows.Controls.Image image = new System.Windows.Controls.Image();
            var img = imageMtx.GetImage(0);
            ImageConverter imgConv = new ImageConverter();

            var bytes = (byte[])imgConv.ConvertTo(img, typeof(byte[]));
            MemoryStream ms = new MemoryStream(bytes);
            BitmapImage bmpImg = new BitmapImage();
            bmpImg.BeginInit();
            bmpImg.StreamSource = ms;
            bmpImg.EndInit();
            image.Source = bmpImg;
            image.Width = image.Width * ScaledWidth;
            image.Height = image.Height * ScaledHeight;

            Grid.SetRow(image, i);
            Grid.SetColumn(image, j);
            CanvasGrid.Children.Add(image);
            j++;
        }