pub struct Image(/* private fields */);Implementations§
Source§impl Image
impl Image
pub fn width(&self) -> i32
pub fn height(&self) -> i32
pub fn mipmaps(&self) -> i32
pub unsafe fn data(&self) -> *mut c_void
Sourcepub fn blur_gaussian(&mut self, blur_size: i32)
pub fn blur_gaussian(&mut self, blur_size: i32)
Apply Gaussian blur using a box blur approximation
Sourcepub fn draw_circle_lines(
&mut self,
center_x: i32,
center_y: i32,
radius: i32,
color: Color,
)
pub fn draw_circle_lines( &mut self, center_x: i32, center_y: i32, radius: i32, color: Color, )
Draw circle outline within an image
Sourcepub fn draw_circle_lines_v(
&mut self,
center: Vector2,
center_y: i32,
color: Color,
)
pub fn draw_circle_lines_v( &mut self, center: Vector2, center_y: i32, color: Color, )
Draw circle outline within an image (Vector version)
pub fn format(&self) -> PixelFormat
pub fn from_image(&self, rec: impl Into<Rectangle>) -> Image
pub fn from_channel(&self, selected_channel: i32) -> Image
Sourcepub fn export_image(&self, filename: &str)
pub fn export_image(&self, filename: &str)
Exports image as a PNG file.
Sourcepub fn export_image_as_code(&self, filename: &str)
pub fn export_image_as_code(&self, filename: &str)
Exports image as a PNG file.
Sourcepub fn get_pixel_data_size(&self) -> usize
pub fn get_pixel_data_size(&self) -> usize
Get pixel data size in bytes (image or texture)
Sourcepub fn get_image_data(&self) -> ImageColors
pub fn get_image_data(&self) -> ImageColors
Gets pixel data from image as a Vec of Color structs.
Sourcepub fn extract_palette(&self, max_palette_size: u32) -> ImagePalette
pub fn extract_palette(&self, max_palette_size: u32) -> ImagePalette
Extract color palette from image to maximum size
Sourcepub fn set_format(&mut self, new_format: PixelFormat)
pub fn set_format(&mut self, new_format: PixelFormat)
Converts image data to desired pixel format.
Sourcepub fn alpha_mask(&mut self, alpha_mask: &Image)
pub fn alpha_mask(&mut self, alpha_mask: &Image)
Applies alpha mask to image.
Alpha mask must be same size as the image. If alpha mask is not greyscale
Ensure the colors are white (255, 255, 255, 255) or black (0, 0, 0, 0)
Sourcepub fn alpha_clear(&mut self, color: impl Into<Color>, threshold: f32)
pub fn alpha_clear(&mut self, color: impl Into<Color>, threshold: f32)
Clears alpha channel on image to desired color.
Sourcepub fn alpha_crop(&mut self, threshold: f32)
pub fn alpha_crop(&mut self, threshold: f32)
Crops image depending on alpha value.
Sourcepub fn alpha_premultiply(&mut self)
pub fn alpha_premultiply(&mut self)
Premultiplies alpha channel on image.
Sourcepub fn resize_nn(&mut self, new_width: i32, new_height: i32)
pub fn resize_nn(&mut self, new_width: i32, new_height: i32)
Resizes image (nearest-neighbor scaling).
Sourcepub fn resize_canvas(
&mut self,
new_width: i32,
new_height: i32,
offset_x: i32,
offset_y: i32,
color: impl Into<Color>,
)
pub fn resize_canvas( &mut self, new_width: i32, new_height: i32, offset_x: i32, offset_y: i32, color: impl Into<Color>, )
Resizes image canvas and fills with color.
Sourcepub fn gen_mipmaps(&mut self)
pub fn gen_mipmaps(&mut self)
Generates all mipmap levels for a provided image.
Sourcepub fn dither(&mut self, r_bpp: i32, g_bpp: i32, b_bpp: i32, a_bpp: i32)
pub fn dither(&mut self, r_bpp: i32, g_bpp: i32, b_bpp: i32, a_bpp: i32)
Dithers image data to 16bpp or lower (Floyd-Steinberg dithering).
Sourcepub fn get_image_alpha_border(&self, threshold: f32) -> Rectangle
pub fn get_image_alpha_border(&self, threshold: f32) -> Rectangle
Get image alpha border rectangle
Sourcepub fn clear_background(&mut self, color: impl Into<Color>)
pub fn clear_background(&mut self, color: impl Into<Color>)
Clear image background with given color
Sourcepub fn draw(
&mut self,
src: &Image,
src_rec: Rectangle,
dst_rec: Rectangle,
tint: impl Into<Color>,
)
pub fn draw( &mut self, src: &Image, src_rec: Rectangle, dst_rec: Rectangle, tint: impl Into<Color>, )
Draws a source image within a destination image.
Sourcepub fn draw_pixel(&mut self, pos_x: i32, pos_y: i32, color: impl Into<Color>)
pub fn draw_pixel(&mut self, pos_x: i32, pos_y: i32, color: impl Into<Color>)
Draw pixel within an image
Sourcepub fn draw_pixel_v(
&mut self,
position: impl Into<Vector2>,
color: impl Into<Color>,
)
pub fn draw_pixel_v( &mut self, position: impl Into<Vector2>, color: impl Into<Color>, )
Draw pixel within an image (Vector version)
Sourcepub fn draw_line(
&mut self,
start_pos_x: i32,
start_pos_y: i32,
end_pos_x: i32,
end_pos_y: i32,
color: impl Into<Color>,
)
pub fn draw_line( &mut self, start_pos_x: i32, start_pos_y: i32, end_pos_x: i32, end_pos_y: i32, color: impl Into<Color>, )
Draw line within an image
Sourcepub fn draw_line_ex(
&mut self,
start_pos: impl Into<Vector2>,
end_pos: impl Into<Vector2>,
thick: i32,
color: impl Into<Color>,
)
pub fn draw_line_ex( &mut self, start_pos: impl Into<Vector2>, end_pos: impl Into<Vector2>, thick: i32, color: impl Into<Color>, )
Draw a line (using triangles/quads)
Sourcepub fn draw_line_v(
&mut self,
start: impl Into<Vector2>,
end: impl Into<Vector2>,
color: impl Into<Color>,
)
pub fn draw_line_v( &mut self, start: impl Into<Vector2>, end: impl Into<Vector2>, color: impl Into<Color>, )
Draw line within an image (Vector version)
Sourcepub fn draw_triangle(
&mut self,
v1: impl Into<Vector2>,
v2: impl Into<Vector2>,
v3: impl Into<Vector2>,
color: impl Into<Color>,
)
pub fn draw_triangle( &mut self, v1: impl Into<Vector2>, v2: impl Into<Vector2>, v3: impl Into<Vector2>, color: impl Into<Color>, )
Draw triangle within an image
Sourcepub fn draw_triangle_ex(
&mut self,
v1: impl Into<Vector2>,
v2: impl Into<Vector2>,
v3: impl Into<Vector2>,
c1: impl Into<Color>,
c2: impl Into<Color>,
c3: impl Into<Color>,
)
pub fn draw_triangle_ex( &mut self, v1: impl Into<Vector2>, v2: impl Into<Vector2>, v3: impl Into<Vector2>, c1: impl Into<Color>, c2: impl Into<Color>, c3: impl Into<Color>, )
Draw triangle with interpolated colors within an image
Sourcepub fn draw_triangle_lines(
&mut self,
v1: impl Into<Vector2>,
v2: impl Into<Vector2>,
v3: impl Into<Vector2>,
color: impl Into<Color>,
)
pub fn draw_triangle_lines( &mut self, v1: impl Into<Vector2>, v2: impl Into<Vector2>, v3: impl Into<Vector2>, color: impl Into<Color>, )
Draw triangle outline within an image
Sourcepub fn draw_triangle_fan(
&mut self,
points: Vec<Vector2>,
color: impl Into<Color>,
)
pub fn draw_triangle_fan( &mut self, points: Vec<Vector2>, color: impl Into<Color>, )
Draw a triangle fan defined by points within an image (first vertex is the center)
Sourcepub fn draw_triangle_strip(
&mut self,
points: Vec<Vector2>,
color: impl Into<Color>,
)
pub fn draw_triangle_strip( &mut self, points: Vec<Vector2>, color: impl Into<Color>, )
Draw a triangle strip defined by points within an image
Sourcepub fn draw_circle(
&mut self,
center_x: i32,
center_y: i32,
radius: i32,
color: impl Into<Color>,
)
pub fn draw_circle( &mut self, center_x: i32, center_y: i32, radius: i32, color: impl Into<Color>, )
Draw circle within an image
Sourcepub fn draw_circle_v(
&mut self,
center: impl Into<Vector2>,
radius: i32,
color: impl Into<Color>,
)
pub fn draw_circle_v( &mut self, center: impl Into<Vector2>, radius: i32, color: impl Into<Color>, )
Draw circle within an image (Vector version)
Sourcepub fn draw_rectangle(
&mut self,
pos_x: i32,
pos_y: i32,
width: i32,
height: i32,
color: impl Into<Color>,
)
pub fn draw_rectangle( &mut self, pos_x: i32, pos_y: i32, width: i32, height: i32, color: impl Into<Color>, )
Draws a rectangle within an image.
Sourcepub fn draw_rectangle_v(
&mut self,
position: impl Into<Vector2>,
size: impl Into<Vector2>,
color: impl Into<Color>,
)
pub fn draw_rectangle_v( &mut self, position: impl Into<Vector2>, size: impl Into<Vector2>, color: impl Into<Color>, )
Draw rectangle within an image (Vector version)
Sourcepub fn draw_rectangle_rec(
&mut self,
rectangle: impl Into<Rectangle>,
color: impl Into<Color>,
)
pub fn draw_rectangle_rec( &mut self, rectangle: impl Into<Rectangle>, color: impl Into<Color>, )
Draw rectangle within an image (Rectangle version)
Sourcepub fn draw_rectangle_lines(
&mut self,
rec: Rectangle,
thickness: i32,
color: impl Into<Color>,
)
pub fn draw_rectangle_lines( &mut self, rec: Rectangle, thickness: i32, color: impl Into<Color>, )
Draws a rectangle within an image.
Sourcepub fn draw_text(
&mut self,
text: &str,
pos_x: i32,
pos_y: i32,
font_size: i32,
color: impl Into<Color>,
)
pub fn draw_text( &mut self, text: &str, pos_x: i32, pos_y: i32, font_size: i32, color: impl Into<Color>, )
Draws text (default font) within an image (destination).
Sourcepub fn draw_text_ex(
&mut self,
font: impl AsRef<Font>,
text: &str,
position: impl Into<Vector2>,
font_size: f32,
spacing: f32,
color: impl Into<Color>,
)
pub fn draw_text_ex( &mut self, font: impl AsRef<Font>, text: &str, position: impl Into<Vector2>, font_size: f32, spacing: f32, color: impl Into<Color>, )
Draws text (default font) within an image (destination).
Sourcepub fn flip_vertical(&mut self)
pub fn flip_vertical(&mut self)
Flips image vertically.
Sourcepub fn flip_horizontal(&mut self)
pub fn flip_horizontal(&mut self)
Flips image horizontally.
Sourcepub fn rotate_ccw(&mut self)
pub fn rotate_ccw(&mut self)
Rotates image counterclockwise by 90 degrees (PI/2 radians).
Sourcepub fn color_tint(&mut self, color: impl Into<Color>)
pub fn color_tint(&mut self, color: impl Into<Color>)
Tints colors in image using specified color.
Sourcepub fn color_invert(&mut self)
pub fn color_invert(&mut self)
Inverts the colors in image.
Sourcepub fn color_grayscale(&mut self)
pub fn color_grayscale(&mut self)
Converts `image color to grayscale.
Sourcepub fn color_contrast(&mut self, contrast: f32)
pub fn color_contrast(&mut self, contrast: f32)
Adjusts the contrast of image.
Sourcepub fn color_brightness(&mut self, brightness: i32)
pub fn color_brightness(&mut self, brightness: i32)
Adjusts the brightness of image.
Sourcepub fn color_replace(
&mut self,
color: impl Into<Color>,
replace: impl Into<Color>,
)
pub fn color_replace( &mut self, color: impl Into<Color>, replace: impl Into<Color>, )
Searches image for all occurences of color and replaces them with replace color.
Sourcepub fn export_image_to_memory(&self, file_type: &str) -> Result<&[u8], Error>
pub fn export_image_to_memory(&self, file_type: &str) -> Result<&[u8], Error>
Export image to memory buffer.
Sourcepub fn kernel_convolution(&mut self, kernel: &[f32]) -> Result<(), Error>
pub fn kernel_convolution(&mut self, kernel: &[f32]) -> Result<(), Error>
Apply custom square convolution kernel to image NOTE: The convolution kernel matrix is expected to be square
Sourcepub fn gen_image_color(
width: i32,
height: i32,
color: impl Into<Color>,
) -> Image
pub fn gen_image_color( width: i32, height: i32, color: impl Into<Color>, ) -> Image
Generates a plain color Image.
Sourcepub fn gen_image_perlin_noise(
&self,
width: i32,
height: i32,
offset_x: i32,
offset_y: i32,
scale: f32,
) -> Image
pub fn gen_image_perlin_noise( &self, width: i32, height: i32, offset_x: i32, offset_y: i32, scale: f32, ) -> Image
Generate image: perlin noise
Sourcepub fn gen_image_gradient_radial(
width: i32,
height: i32,
density: f32,
inner: impl Into<Color>,
outer: impl Into<Color>,
) -> Image
pub fn gen_image_gradient_radial( width: i32, height: i32, density: f32, inner: impl Into<Color>, outer: impl Into<Color>, ) -> Image
Generates an Image containing a radial gradient.
Sourcepub fn gen_image_checked(
width: i32,
height: i32,
checks_x: i32,
checks_y: i32,
col1: impl Into<Color>,
col2: impl Into<Color>,
) -> Image
pub fn gen_image_checked( width: i32, height: i32, checks_x: i32, checks_y: i32, col1: impl Into<Color>, col2: impl Into<Color>, ) -> Image
Generates an Image containing a checkerboard pattern.
Sourcepub fn gen_image_gradient_linear(
width: i32,
height: i32,
direction: i32,
start: Color,
end: Color,
) -> Image
pub fn gen_image_gradient_linear( width: i32, height: i32, direction: i32, start: Color, end: Color, ) -> Image
Generate images an image linear gradient.
direction in expected to be degrees [0..360]. 0 results in a vertical gradient
Sourcepub fn gen_image_gradient_square(
width: i32,
height: i32,
density: f32,
start: Color,
end: Color,
) -> Image
pub fn gen_image_gradient_square( width: i32, height: i32, density: f32, start: Color, end: Color, ) -> Image
Generate images an image with a square gradient
For best results, density should be `0.0..1.0``
pub fn gen_image_text(width: i32, height: i32, text: &str) -> Image
Sourcepub fn gen_image_white_noise(width: i32, height: i32, factor: f32) -> Image
pub fn gen_image_white_noise(width: i32, height: i32, factor: f32) -> Image
Generates an Image containing white noise.
Sourcepub fn gen_image_cellular(width: i32, height: i32, tile_size: i32) -> Image
pub fn gen_image_cellular(width: i32, height: i32, tile_size: i32) -> Image
Generates an Image using a cellular algorithm. Bigger tile_size means bigger cells.
Sourcepub fn load_image(filename: &str) -> Result<Image, Error>
pub fn load_image(filename: &str) -> Result<Image, Error>
Loads image from file into CPU memory (RAM).
Sourcepub fn load_image_from_mem(filetype: &str, bytes: &[u8]) -> Result<Image, Error>
pub fn load_image_from_mem(filetype: &str, bytes: &[u8]) -> Result<Image, Error>
Loads image from a given memory buffer The input data is expected to be in a supported file format such as png. Which formats are supported depend on the build flags used for the raylib (C) library.
Sourcepub fn load_image_anim(filename: &str, frame_num: &mut i32) -> Image
pub fn load_image_anim(filename: &str, frame_num: &mut i32) -> Image
Load image sequence from file, with the number of frames loaded saved to frame_num. Image.data buffer includes all frames. All frames returned are in RGBA format. Frames delay data is discarded
Sourcepub fn load_image_anim_from_memory(
filetype: &str,
data: &[u8],
frame_num: &mut i32,
) -> Image
pub fn load_image_anim_from_memory( filetype: &str, data: &[u8], frame_num: &mut i32, ) -> Image
Load image from memory buffer, with the number of frames loaded saved to frame_num. fileType refers to extension: i.e. “.png”. File extension must be provided in lower-case
Sourcepub fn load_image_raw(
filename: &str,
width: i32,
height: i32,
format: i32,
header_size: i32,
) -> Result<Image, Error>
pub fn load_image_raw( filename: &str, width: i32, height: i32, format: i32, header_size: i32, ) -> Result<Image, Error>
Loads image from RAW file data.
Sourcepub fn image_text(text: &str, font_size: i32, color: impl Into<Color>) -> Image
pub fn image_text(text: &str, font_size: i32, color: impl Into<Color>) -> Image
Creates an image from text (custom font).
Sourcepub fn image_text_ex(
font: impl AsRef<Font>,
text: &str,
font_size: f32,
spacing: f32,
tint: impl Into<Color>,
) -> Image
pub fn image_text_ex( font: impl AsRef<Font>, text: &str, font_size: f32, spacing: f32, tint: impl Into<Color>, ) -> Image
Creates an image from text (custom font).