use base::CGFloat; use core_foundation::base::{CFRetain, CFTypeID}; use core_foundation::data::CFData; use color_space::CGColorSpace; use data_provider::{CGDataProviderRef, CGDataProvider}; use geometry::CGRect; use libc::size_t; use foreign_types::{ForeignType, ForeignTypeRef};
#[repr(C)] pubenum CGImageAlphaInfo {
CGImageAlphaNone, /* For example, RGB. */
CGImageAlphaPremultipliedLast, /* For example, premultiplied RGBA */
CGImageAlphaPremultipliedFirst, /* For example, premultiplied ARGB */
CGImageAlphaLast, /* For example, non-premultiplied RGBA */
CGImageAlphaFirst, /* For example, non-premultiplied ARGB */
CGImageAlphaNoneSkipLast, /* For example, RBGX. */
CGImageAlphaNoneSkipFirst, /* For example, XRBG. */
CGImageAlphaOnly /* No color data, alpha data only */
}
pubfn color_space(&self) -> CGColorSpace { unsafe { let cs = CGImageGetColorSpace(self.as_ptr());
CFRetain(cs as *mut _);
CGColorSpace::from_ptr(cs)
}
}
/// Returns the raw image bytes wrapped in `CFData`. Note, the returned `CFData` owns the /// underlying buffer. pubfn data(&self) -> CFData { let data_provider = unsafe {
CGDataProviderRef::from_ptr(CGImageGetDataProvider(self.as_ptr()))
};
data_provider.copy_data()
}
/// Returns a cropped image. If the `rect` specifies a rectangle which lies outside of the /// image bounds, the `None` is returned. pubfn cropped(&self, rect: CGRect) -> Option<CGImage> { let image_ptr = unsafe { CGImageCreateWithImageInRect(self.as_ptr(), rect) }; if !image_ptr.is_null() {
Some(unsafe { CGImage::from_ptr(image_ptr) })
} else {
None
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.