Module: graphics.image
Source: ./graphics/image.reef
Overview
graphics/image.reef - Image types and pixel operations Part of reef-stdlib graphics module
Types
PixelFormat (enum)
Variants:
RGBA8BGRA8RGB8BGR8Grayscale8GrayscaleAlpha16Alpha8
Image
Fields:
| Name | Type |
|---|---|
width |
int |
height |
int |
format |
PixelFormat |
stride |
int |
data |
[uint8] |
Functions
fn bytes_per_pixel(format: PixelFormat): int
Get bytes per pixel for a format
fn has_alpha(format: PixelFormat): bool
Check if format has alpha channel
fn create_image(width: int, height: int, format: PixelFormat): Image
Create image with specified format
fn create_image_rgba(width: int, height: int): Image
Create RGBA image (most common)
fn create_image_rgb(width: int, height: int): Image
Create RGB image (no alpha)
fn create_image_grayscale(width: int, height: int): Image
Create grayscale image
fn image_width(img: Image): int
fn image_height(img: Image): int
fn image_format(img: Image): PixelFormat
fn image_stride(img: Image): int
fn image_data(img: Image): [uint8]
fn get_pixel(img: Image, x: int, y: int): core.Color
Get pixel at (x, y) as Color
fn clone_image(img: Image): Image
Clone an image
fn sub_image(img: Image, r: core.Rect): Image
Create a sub-image (view into original - copies data)
fn flip_horizontal(img: Image): Image
Flip image horizontally (left-right mirror)
fn flip_vertical(img: Image): Image
Flip image vertically (top-bottom mirror)
fn rotate_90(img: Image): Image
Rotate image 90 degrees clockwise
fn rotate_180(img: Image): Image
Rotate image 180 degrees
fn rotate_270(img: Image): Image
Rotate image 270 degrees clockwise (= 90 counter-clockwise)
fn scale_nearest(img: Image, new_width: int, new_height: int): Image
Scale image using nearest-neighbor interpolation
fn crop(img: Image, x: int, y: int, w: int, h: int): Image
Crop a region from the image
Procedures
proc set_pixel(img: Image, x: int, y: int, c: core.Color)
Set pixel at (x, y) from Color
proc clear(img: Image, c: core.Color)
Clear entire image to a color
proc fill_rect(img: Image, r: core.Rect, c: core.Color)
Fill a rectangle with a color
proc copy_rect(src: Image, src_rect: core.Rect, dst: Image, dst_x: int, dst_y: int)
Copy a rectangle from source to destination
proc blit(src: Image, dst: Image, dst_x: int, dst_y: int)
Blit (copy) source image onto destination (no alpha blending)
proc blit_alpha(src: Image, dst: Image, dst_x: int, dst_y: int)
Blit with alpha blending
Generated by reefc doc