public void DDA() { var pc = new WpfPixelCanvas(10, 10); pc.DrawLineDDA(1, 1, 9, 9, System.Windows.Media.Colors.DeepPink); //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(10, 10); //for (int w = 0; w < pc.Width; w++) // for (int h = 0; h < pc.Height; h++) // { // bmp.SetPixel(w, h, pc.GetColor(pc[w, h])); // } var bmp = pc.ToFrozenWriteableBitmap(); using (FileStream fs = new FileStream(@"c:\temp\2.bmp", FileMode.OpenOrCreate)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(fs); fs.Close(); } //bmp.Save(@"C:\temp\1.bmp"); }
public void Blit() { var pc_1 = new WpfPixelCanvas(10, 10); pc_1.DrawLineDDA(1, 1, 9, 9, System.Windows.Media.Colors.DeepPink); var pc_2 = new WpfPixelCanvas(10, 10); pc_2.DrawLineDDA(1, 9, 9, 1, System.Windows.Media.Colors.DeepPink); var bmp = pc_1.ToFrozenWriteableBitmap(); using (FileStream fs = new FileStream(@"c:\temp\1.bmp", FileMode.OpenOrCreate)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(fs); fs.Close(); } bmp = pc_2.ToFrozenWriteableBitmap(); using (FileStream fs = new FileStream(@"c:\temp\2.bmp", FileMode.OpenOrCreate)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(fs); fs.Close(); } pc_1.Blit(new System.Drawing.Rectangle(0, 0, 10, 10), pc_2, new System.Drawing.Rectangle(0,0,10,10), 255, 255, 255, 255, PixelCanvas.BlendMode.Alpha); bmp = pc_1.ToFrozenWriteableBitmap(); using (FileStream fs = new FileStream(@"c:\temp\3.bmp", FileMode.OpenOrCreate)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(fs); fs.Close(); } //bmp.Save(@"C:\temp\1.bmp"); }
public void DDA_Horizontal() { for (int i = 1; i < 9; i++) { var pc = new WpfPixelCanvas(10, 10); pc.DrawLineDDA(1, 0, i, 0, System.Windows.Media.Colors.DeepPink); var bmp = pc.ToFrozenWriteableBitmap(); using (FileStream fs = new FileStream(@"c:\temp\DDA_Horizontal_{0}.bmp".FormatWith(i), FileMode.OpenOrCreate)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(fs); fs.Close(); } } }