mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Qualify PixelsByColorType.
This commit is contained in:
parent
d759b07299
commit
1130c1dced
2 changed files with 8 additions and 8 deletions
|
@ -23,7 +23,7 @@ use geom::side_offsets::SideOffsets2D;
|
|||
use geom::size::Size2D;
|
||||
use libc::size_t;
|
||||
use libc::types::common::c99::{uint16_t, uint32_t};
|
||||
use png::{RGB8, RGBA8, K8, KA8};
|
||||
use png::PixelsByColorType;
|
||||
use servo_net::image::base::Image;
|
||||
use servo_util::geometry::{Au, MAX_RECT};
|
||||
use servo_util::opts;
|
||||
|
@ -123,10 +123,10 @@ impl<'a> PaintContext<'a> {
|
|||
pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<Box<Image>>) {
|
||||
let size = Size2D(image.width as i32, image.height as i32);
|
||||
let (pixel_width, pixels, source_format) = match image.pixels {
|
||||
RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
||||
K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8),
|
||||
RGB8(_) => panic!("RGB8 color type not supported"),
|
||||
KA8(_) => panic!("KA8 color type not supported"),
|
||||
PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
||||
PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8),
|
||||
PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
|
||||
PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
|
||||
};
|
||||
let stride = image.width * pixel_width;
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
|||
match png::load_png_from_memory(buffer) {
|
||||
Ok(mut png_image) => {
|
||||
match png_image.pixels {
|
||||
png::RGB8(ref mut data) => byte_swap(data.as_mut_slice()),
|
||||
png::RGBA8(ref mut data) => {
|
||||
png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data.as_mut_slice()),
|
||||
png::PixelsByColorType::RGBA8(ref mut data) => {
|
||||
byte_swap_and_premultiply(data.as_mut_slice())
|
||||
}
|
||||
_ => {}
|
||||
|
@ -72,7 +72,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
|||
Some(png::Image {
|
||||
width: image.width as u32,
|
||||
height: image.height as u32,
|
||||
pixels: png::RGBA8(image.data)
|
||||
pixels: png::PixelsByColorType::RGBA8(image.data)
|
||||
})
|
||||
}
|
||||
stb_image::ImageF32(_image) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue