allegro_sys/
bitmap.rs

1// Copyright (c) 2014 by SiegeLord
2//
3// All rights reserved. Distributed under ZLib. For full terms see the file LICENSE.
4
5use crate::color::ALLEGRO_COLOR;
6
7use allegro_util::c_bool;
8use libc::*;
9
10allegro_util::opaque!(ALLEGRO_BITMAP);
11
12pub const ALLEGRO_MEMORY_BITMAP: u32 = 1;
13pub const ALLEGRO_KEEP_BITMAP_FORMAT: u32 = 2;
14pub const ALLEGRO_FORCE_LOCKING: u32 = 4;
15pub const ALLEGRO_NO_PRESERVE_TEXTURE: u32 = 8;
16pub const ALLEGRO_ALPHA_TEST: u32 = 16;
17pub const _ALLEGRO_INTERNAL_OPENGL: u32 = 32;
18pub const ALLEGRO_MIN_LINEAR: u32 = 64;
19pub const ALLEGRO_MAG_LINEAR: u32 = 128;
20pub const ALLEGRO_MIPMAP: u32 = 256;
21pub const ALLEGRO_NO_PREMULTIPLIED_ALPHA: u32 = 512;
22pub const ALLEGRO_VIDEO_BITMAP: u32 = 1024;
23pub const ALLEGRO_CONVERT_BITMAP: u32 = 2048;
24
25#[repr(C)]
26pub struct ALLEGRO_LOCKED_REGION
27{
28	pub data: *const c_void,
29	pub format: c_int,
30	pub pitch: c_int,
31	pub pixel_size: c_int,
32}
33
34pub const ALLEGRO_LOCK_READWRITE: u32 = 0;
35pub const ALLEGRO_LOCK_READONLY: u32 = 1;
36pub const ALLEGRO_LOCK_WRITEONLY: u32 = 2;
37
38unsafe extern "C" {
39	pub fn al_set_new_bitmap_format(format: c_int);
40	pub fn al_set_new_bitmap_depth(depth: c_int);
41	pub fn al_set_new_bitmap_flags(flags: c_int);
42	pub fn al_get_new_bitmap_format() -> c_int;
43	pub fn al_get_new_bitmap_depth() -> c_int;
44	pub fn al_get_new_bitmap_flags() -> c_int;
45	pub fn al_add_new_bitmap_flag(flag: c_int);
46
47	pub fn al_get_bitmap_width(bitmap: *mut ALLEGRO_BITMAP) -> c_int;
48	pub fn al_get_bitmap_height(bitmap: *mut ALLEGRO_BITMAP) -> c_int;
49	pub fn al_get_bitmap_format(bitmap: *mut ALLEGRO_BITMAP) -> c_int;
50	pub fn al_get_bitmap_flags(bitmap: *mut ALLEGRO_BITMAP) -> c_int;
51
52	pub fn al_create_bitmap(w: c_int, h: c_int) -> *mut ALLEGRO_BITMAP;
53	pub fn al_destroy_bitmap(bitmap: *mut ALLEGRO_BITMAP);
54
55	pub fn al_put_pixel(x: c_int, y: c_int, color: ALLEGRO_COLOR);
56	pub fn al_put_blended_pixel(x: c_int, y: c_int, color: ALLEGRO_COLOR);
57	pub fn al_get_pixel(bitmap: *mut ALLEGRO_BITMAP, x: c_int, y: c_int) -> ALLEGRO_COLOR;
58
59	pub fn al_convert_mask_to_alpha(bitmap: *mut ALLEGRO_BITMAP, mask_color: ALLEGRO_COLOR);
60
61	pub fn al_set_clipping_rectangle(x: c_int, y: c_int, width: c_int, height: c_int);
62	pub fn al_reset_clipping_rectangle();
63	pub fn al_get_clipping_rectangle(x: *mut c_int, y: *mut c_int, w: *mut c_int, h: *mut c_int);
64
65	pub fn al_create_sub_bitmap(
66		parent: *mut ALLEGRO_BITMAP, x: c_int, y: c_int, w: c_int, h: c_int,
67	) -> *mut ALLEGRO_BITMAP;
68	pub fn al_is_sub_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> c_bool;
69	pub fn al_get_parent_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> *mut ALLEGRO_BITMAP;
70
71	pub fn al_clone_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> *mut ALLEGRO_BITMAP;
72
73	pub fn al_lock_bitmap(
74		bitmap: *mut ALLEGRO_BITMAP, format: c_int, flags: c_int,
75	) -> *mut ALLEGRO_LOCKED_REGION;
76	pub fn al_unlock_bitmap(bitmap: *mut ALLEGRO_BITMAP);
77}