示例#1
0
 public void CreateNewImage(int width, int height)
 {
     _simplePaintViewModel.SetStride(width * _simplePaintViewModel.GetBytesPerPixel());
     _simplePaintViewModel.SetWidth(width);
     _simplePaintViewModel.SetHeight(height);
     _simplePaintViewModel.ImageSave.Clear();
     _simplePaintViewModel.Imagesource = BitmapSource.Create(_simplePaintViewModel.GetWidth(), _simplePaintViewModel.GetHeight(), 400, 400, PixelFormats.Bgr24, null, _simplePaintViewModel.GetImageData(), _simplePaintViewModel.GetStride());
     _simplePaintViewModel.ImageSave.Push(new TempImage(_simplePaintViewModel.Imagesource, _simplePaintViewModel.GetStride()));
     _simplePaintViewModel.SetFirstImage(_simplePaintViewModel.Imagesource);
 }
示例#2
0
 private void OpenImage(BitmapSource b)
 {
     _simplePaintViewModel.SetImageData(new byte[b.PixelHeight * b.PixelWidth * (b.Format.BitsPerPixel / 8)]);
     b.CopyPixels(_simplePaintViewModel.GetImageData(), b.PixelWidth * (b.Format.BitsPerPixel / 8), 0);
     _simplePaintViewModel.SetWidth(b.PixelWidth);
     _simplePaintViewModel.SetHeight(b.PixelHeight);
     _simplePaintViewModel.SetBytesPerPixel(b.Format.BitsPerPixel / 8);
     _simplePaintViewModel.SetStride(_simplePaintViewModel.GetBytesPerPixel() * b.PixelWidth);
     _simplePaintViewModel.ImageSave.Clear();
     _simplePaintViewModel.Imagesource = BitmapSource.Create(b.PixelWidth, b.PixelHeight, b.DpiX, b.DpiY, b.Format, b.Palette, _simplePaintViewModel.GetImageData(), _simplePaintViewModel.GetStride());
     _simplePaintViewModel.SetFirstImage(_simplePaintViewModel.Imagesource);
     _simplePaintViewModel.ImageSave.Push((new TempImage(_simplePaintViewModel.Imagesource, _simplePaintViewModel.Imagesource.PixelWidth * _simplePaintViewModel.Imagesource.Format.BitsPerPixel / 8)));
 }