refactor(pdf): rename icc_profile to be more clear

This commit is contained in:
frozolotl 2024-12-28 14:10:10 +01:00
parent 8453fa7218
commit 1cf412312c

View File

@ -36,7 +36,7 @@ pub fn write_images(
bits_per_component, bits_per_component,
width, width,
height, height,
icc_profile, compressed_icc,
alpha, alpha,
interpolate, interpolate,
} => { } => {
@ -52,7 +52,7 @@ pub fn write_images(
let mut icc_ref = None; let mut icc_ref = None;
let space = image.color_space(); let space = image.color_space();
if icc_profile.is_some() { if compressed_icc.is_some() {
let id = chunk.alloc.bump(); let id = chunk.alloc.bump();
space.icc_based(id); space.icc_based(id);
icc_ref = Some(id); icc_ref = Some(id);
@ -82,8 +82,10 @@ pub fn write_images(
image.finish(); image.finish();
} }
if let (Some(icc_profile), Some(icc_ref)) = (icc_profile, icc_ref) { if let (Some(compressed_icc), Some(icc_ref)) =
let mut stream = chunk.icc_profile(icc_ref, icc_profile); (compressed_icc, icc_ref)
{
let mut stream = chunk.icc_profile(icc_ref, compressed_icc);
stream.filter(Filter::FlateDecode); stream.filter(Filter::FlateDecode);
match color_space { match color_space {
ColorSpace::Srgb => { ColorSpace::Srgb => {
@ -206,7 +208,7 @@ fn encode_raster_image(
bits_per_component, bits_per_component,
width: image.width(), width: image.width(),
height: image.height(), height: image.height(),
icc_profile: compressed_icc, compressed_icc,
alpha, alpha,
interpolate, interpolate,
} }
@ -261,8 +263,8 @@ pub enum EncodedImage {
width: u32, width: u32,
/// The image's height. /// The image's height.
height: u32, height: u32,
/// The image's ICC profile, pre-deflated, if any. /// The image's ICC profile, deflated, if any.
icc_profile: Option<Vec<u8>>, compressed_icc: Option<Vec<u8>>,
/// The alpha channel of the image, pre-deflated, if any. /// The alpha channel of the image, pre-deflated, if any.
alpha: Option<(Vec<u8>, Filter)>, alpha: Option<(Vec<u8>, Filter)>,
/// Whether image interpolation should be enabled. /// Whether image interpolation should be enabled.