1
1
use libc:: c_void;
2
- use ui_sys:: { self , uiPixmapImage, uiImageData, uiNewPixmapImage,
3
- uiFreePixmapImage, uiPixmapImageGetFormat, uiPixmapImageGetData,
4
- uiImageLoadPixmap32Raw, uiDrawPixmapImage} ;
5
- use ui_sys:: uiDrawContext;
2
+ use ui_sys:: { uiPixmapImage, uiImageData, uiNewPixmapImage,
3
+ uiFreePixmapImage, uiPixmapImageGetData,
4
+ uiImageLoadPixmap32Raw} ;
6
5
7
6
pub struct Image {
8
7
ui_image : * mut uiPixmapImage
9
8
}
10
9
11
10
// #define uiPixmap32FormatOffsets(a,r,g,b) ((a) << 0 | (r) << 2 | (g) << 4 | (b) << 6)
12
- const uiPixmap32FormatOffsetMask : u32 = 0x0ff ;
13
- const uiPixmap32FormatHasAlpha : u32 = 0x100 ;
14
- const uiPixmap32FormatAlphaPremultiplied : u32 = 0x200 ;
15
- const uiPixmap32FormatZeroRowBottom : u32 = 0x400 ;
11
+ const _UI_PIXMAP32_FORMAT_OFFSET_MASK : u32 = 0x0ff ;
12
+ const _UI_PIXMAP32_FORMAT_HAS_ALPHA : u32 = 0x100 ;
13
+ const _UI_PIXMAP32_FORMAT_ALPHA_PREMULTIPLIED : u32 = 0x200 ;
14
+ const _UI_PIXMAP32_FORMAT_ZERO_ROW_BOTTOM : u32 = 0x400 ;
16
15
17
16
impl Image {
18
17
pub fn new ( w : i32 , h : i32 ) -> Image {
19
- unsafe {
20
- Image {
21
- ui_image : uiNewPixmapImage ( w, h)
22
- }
18
+ Image {
19
+ ui_image : unsafe { uiNewPixmapImage ( w, h) }
23
20
}
24
21
}
25
22
@@ -33,7 +30,16 @@ impl Image {
33
30
// uiImageLoadPixmap32Raw(uiImage *img, int x, int y, int width, int height,
34
31
// int rowstrideBytes, uiPixmap32Format fmt, void *data);
35
32
let img_data = get_image_data ( self . ui_image ) ;
36
- uiImageLoadPixmap32Raw ( self . ui_image , offset_x, offset_y, w, h, w* 4 , img_data. fmt , data. as_ptr ( ) as * const c_void ) ;
33
+ uiImageLoadPixmap32Raw (
34
+ self . ui_image ,
35
+ offset_x,
36
+ offset_y,
37
+ w,
38
+ h,
39
+ w* 4 ,
40
+ img_data. fmt ,
41
+ data. as_ptr ( ) as * const c_void
42
+ ) ;
37
43
}
38
44
}
39
45
}
@@ -53,8 +59,6 @@ fn get_image_data(img: *const uiPixmapImage) -> uiImageData {
53
59
rowstride : 0 ,
54
60
data : ptr:: null_mut ( ) ,
55
61
} ;
56
-
57
62
unsafe { uiPixmapImageGetData ( img, & mut d) }
58
-
59
63
d
60
64
}
0 commit comments