pebble_rust/pebble/
types.rs

1/*
2 * This file is part of pebble-rust.
3 * Copyright (c) 2019 RoccoDev
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19pub use crate::pebble::internal::types::{GColor, GRect, GPoint, GSize, tm, TimeUnits, GCompOp};
20use crate::pebble::internal::types::GBitmap;
21use crate::pebble::internal::functions::{interface, declarations};
22
23pub struct Bitmap {
24    pub internal: *mut GBitmap
25}
26
27impl Bitmap {
28    pub fn new(resource_id: u32) -> Bitmap {
29        let internal = interface::gbitmap_create_with_resource(resource_id);
30        Bitmap {internal}
31    }
32
33    pub fn clean(self) {
34        unsafe {
35            declarations::gbitmap_destroy(self.internal);
36        }
37        drop(self);
38    }
39}