2using System.Collections.Generic;
4using System.Drawing.Imaging;
6using System.Runtime.InteropServices;
8using System.Threading.Tasks;
23 IntPtr Iptr = IntPtr.Zero;
24 BitmapData bitmapData =
null;
33 public int Depth {
get;
private set; }
37 public int Width {
get;
private set; }
41 public int Height {
get;
private set; }
67 Rectangle rect =
new Rectangle(0, 0,
Width,
Height);
70 Depth =
System.Drawing.Bitmap.GetPixelFormatSize(source.PixelFormat);
75 throw new ArgumentException(
"Only 8, 24 and 32 bpp images are supported.");
79 bitmapData = source.LockBits(rect, ImageLockMode.ReadWrite,
84 Pixels =
new byte[PixelCount * step];
85 Iptr = bitmapData.Scan0;
107 source.UnlockBits(bitmapData);
123 Color clr = Color.Empty;
126 int cCount =
Depth / 8;
129 int i = ((y *
Width) + x) * cCount;
131 if (i >
Pixels.Length - cCount)
132 throw new IndexOutOfRangeException();
140 clr = Color.FromArgb(a, r, g, b);
147 clr = Color.FromArgb(r, g, b);
153 clr = Color.FromArgb(c, c, c);
167 int cCount =
Depth / 8;
170 int i = ((y *
Width) + x) * cCount;
The LockBitmap class provides very efficient SetPixel and GetPixel functionality of a bitmap by using...
Color GetPixel(int x, int y)
Get the color of the specified pixel
void SetPixel(int x, int y, Color color)
Set the color of the specified pixel
LockBitmap(Bitmap source)
Sets the source bitmap.
void UnlockBits()
Unlock bitmap data, releasing its underlying data.
int Width
Returns the width of the bitmap.
byte[] Pixels
Get/set the raw pixel byte data.
int Depth
Returns the depth of the bitmap.
int Height
Returns the height of the bitmap.
void LockBits()
Lock bitmap data to access its underlying raw data.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.