public Bitmap(int width, int height, PixelFormat pixelFormat, byte[] imageData, Color[] palette) { if (imageData == null) { throw new Exception("1"); } if (pixelFormat.IsIndexed) { if (palette == null) { throw new Exception("2"); } else if (palette.Length > (int)Math.Pow(2, pixelFormat.BitsPerPixel)) { throw new Exception("3"); } } int stride = ImageHelper.GetStride(pixelFormat, width); if (stride * height != imageData.Length) { throw new Exception("4"); } if (pixelFormat.IsIndexed) { bitmapDataBase = new BitmapDataIndexed(width, height, pixelFormat, imageData.Copy(), palette); } else { bitmapDataBase = new BitmapData(width, height, pixelFormat, imageData.Copy()); } }
public Bitmap(int width, int height, Color[] pixels) { if (pixels == null) { throw new Exception("1"); } if (width * height != pixels.Length) { throw new Exception("2"); } bitmapDataBase = new BitmapDataUndefined(width, height, pixels); }
internal Bitmap(BitmapDataBase bitmapDataBase) { this.bitmapDataBase = bitmapDataBase; }