Method: FreeImage::Bitmap.create
- Defined in:
- lib/free-image/bitmap.rb
.create(width, height, bits_per_pixel, red_mask = 0, green_mask = 0, blue_mask = 0) ⇒ Object
Creates a new image with the specified width, height and bits per pixel.
Parameters
- width
-
The width of the new image
- height
-
The height of the new image
- bits_per_pixel
-
The size in bits of a pixel
- red_mask
-
The bit-layout of the red color component in a bitmap
green_mask:P: The bit-layout of the green color component in a bitmap
- blue_mask
-
The bit-layout of the blue color component in a bitmap
The last three parameter are used to tell FreeImage the bit-layout of the color components in the bitmap, e.g. where in a pixel the red, green and blue components are stored.
To give you an idea about how to interpret the color masks: when red_mask is 0xFF000000 this means that the last 8 bits in one pixel are used for the color red. When green_mask is 0x000000FF, it means that the first 8 bits in a pixel are used for the color green.
The new image is initially filled completely with zeroes. Zero in a image is usually interpreted as black. This means that if your bitmap is palletized it will contain a completely black palette. You can access, and hence populate the palette via #palette.
For 8-bit images, a default greyscale palette will also be created.
74 75 76 77 78 |
# File 'lib/free-image/bitmap.rb', line 74 def self.create(width, height, bits_per_pixel, red_mask = 0, green_mask = 0, blue_mask = 0) ptr = FreeImage.FreeImage_Allocate(width, height, bits_per_pixel, red_mask, green_mask, blue_mask) FreeImage.check_last_error new(ptr) end |