public ActualImage(int width, int height, PixelFormat format)
{
//width and height must >0
this.width = width;
this.height = height;
switch (this.pixelFormat = format)
{
case PixelFormat.ARGB32:
{
this.bitDepth = 32;
this.stride = width * (32 / 8);
this.pixelBuffer = new byte[stride * height];
}
break;
case PixelFormat.GrayScale8:
{
this.bitDepth = 8; //bit per pixel
int bytesPerPixel = (bitDepth + 7) / 8;
this.stride = 4 * ((width * bytesPerPixel + 3) / 4);
this.pixelBuffer = new byte[stride * height];
}
break;
case PixelFormat.RGB24:
{
this.bitDepth = 24; //bit per pixel
int bytesPerPixel = (bitDepth + 7) / 8;
this.stride = 4 * ((width * bytesPerPixel + 3) / 4);
this.pixelBuffer = new byte[stride * height];
}
break;
default:
throw new NotSupportedException();
}
}
public override void Dispose()