Example #1
0
        public Bitmap(int width, int height, short bpp)
        {
            if (bpp != 24 && bpp != 32)
            {
                throw new ArgumentOutOfRangeException("bpp");
            }
            width         = Math.Abs(width);
            height        = Math.Abs(height);
            this.rowSize  = (int)((bpp * width / 32.0f) * 4.0f);
            this.rowSize += (4 - (this.rowSize % 4)) % 4; // Padding
            int pixelArraySize = rowSize * height;
            int fileSize       = BITMAP_HEADER_SIZE + pixelArraySize;

            this.pixels = new byte[pixelArraySize];

            this.fileHeader = new BitmapFileHeader(fileSize, BITMAP_HEADER_SIZE);
            this.v4header   = new BitmapV4Header(width, -height, bpp);
        }
Example #2
0
        public Bitmap(int width, int height, short bpp)
        {
            if (bpp != 24 && bpp != 32)
            {
                throw new ArgumentOutOfRangeException("bpp");
            }
            width = Math.Abs(width);
            height = Math.Abs(height);
            this.rowSize = (int)((bpp * width / 32.0f) * 4.0f);
            this.rowSize += (4 - (this.rowSize % 4)) % 4; // Padding
            int pixelArraySize = rowSize * height;
            int fileSize = BITMAP_HEADER_SIZE + pixelArraySize;
            this.pixels = new byte[pixelArraySize];

            this.fileHeader = new BitmapFileHeader(fileSize, BITMAP_HEADER_SIZE);
            this.v4header = new BitmapV4Header(width, -height, bpp);
        }