Test
This commit is contained in:
@@ -105,6 +105,7 @@ impl CGContext {
|
||||
bytes_per_row,
|
||||
space.as_concrete_TypeRef(),
|
||||
bitmap_info);
|
||||
assert!(!result.is_null());
|
||||
TCFType::wrap_under_create_rule(result)
|
||||
}
|
||||
}
|
||||
@@ -223,6 +224,30 @@ impl CGContext {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_bitmap_context_test() {
|
||||
use geometry::*;
|
||||
|
||||
let cs = CGColorSpace::create_device_rgb();
|
||||
let ctx = CGContext::create_bitmap_context(None,
|
||||
16, 8,
|
||||
8, 0,
|
||||
&cs,
|
||||
::base::kCGImageAlphaPremultipliedLast);
|
||||
ctx.set_rgb_fill_color(1.,0.,1.,1.);
|
||||
ctx.fill_rect(CGRect::new(&CGPoint::new(0.,0.), &CGSize::new(8.,8.)));
|
||||
let img = ctx.create_image().unwrap();
|
||||
assert_eq!(16, img.width());
|
||||
assert_eq!(8, img.height());
|
||||
assert_eq!(8, img.bits_per_component());
|
||||
assert_eq!(32, img.bits_per_pixel());
|
||||
let data = img.data();
|
||||
assert_eq!(255, data.bytes()[0]);
|
||||
assert_eq!(0, data.bytes()[1]);
|
||||
assert_eq!(255, data.bytes()[2]);
|
||||
assert_eq!(255, data.bytes()[3]);
|
||||
}
|
||||
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
extern {
|
||||
fn CGBitmapContextCreate(data: *mut c_void,
|
||||
|
||||
Reference in New Issue
Block a user