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
|
Bitmap bmp = Affichage.Properties.Resources.punaise_centre;
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
bmp.PixelFormat);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
int bytes = bmpData.Stride * bmp.Height;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
PixelFormat pf = PixelFormats.Bgr32;
int rawStride = (bmp.Width * pf.BitsPerPixel + 7) / 8;
//// Create a BitmapSource.
BitmapSource bitmap = BitmapSource.Create(bmp.Width, bmp.Height,
96, 96, pf, null,
rgbValues, rawStride);
ImageDrawing ig = new ImageDrawing(
(ImageSource)bitmap,
new System.Windows.Rect(
pixW,
pixH,
size.Width,
size.Height
)); |
Partager