1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// Initialize the WriteableBitmap with size 512x512 and set it as source of an Image control
WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);
writeableBmp.GetBitmapContext();
// Clear the WriteableBitmap with white color
writeableBmp.Clear(Colors.White);
// Set the pixel at P(10, 13) to black
writeableBmp.SetPixel(10, 13, Colors.Black);
// Get the color of the pixel at P(30, 43)
Color color = writeableBmp.GetPixel(30, 43);
// Green line from P1(1, 2) to P2(30, 40)
writeableBmp.DrawLine(1, 2, 30, 40, Colors.Green);
// Blue anti-aliased line from P1(10, 20) to P2(50, 70)
writeableBmp.DrawLineAa(10, 20, 50, 70, Colors.Blue);
// Black triangle with the points P1(10, 5), P2(20, 40) and P3(30, 10)
writeableBmp.DrawTriangle(10, 5, 20, 40, 30, 10, Colors.Black);
// Red rectangle from the point P1(2, 4) that is 10px wide and 6px high
writeableBmp.DrawRectangle(2, 4, 12, 10, Colors.Red);
// Filled blue ellipse with the center point P1(2, 2) that is 8px wide and 5px high
writeableBmp.FillEllipseCentered(2, 2, 8, 5, Colors.Blue);
// Closed green polyline with P1(10, 5), P2(20, 40), P3(30, 30) and P4(7, 8)
int[] p = new int[] { 10, 5, 20, 40, 30, 30, 7, 8, 10, 5 };
writeableBmp.DrawPolyline(p, Colors.Green);
//Update picture
writeableBmp.Invalidate();
ImageControl.Source = writeableBmp; |
Partager