Skip to content

Commit

Permalink
Merge pull request crlf0710#182 from burrbull/test2
Browse files Browse the repository at this point in the history
pdf_add_dict -> dict.set()
  • Loading branch information
crlf0710 authored Nov 21, 2019
2 parents aa32de5 + 8b1b212 commit 7cd148e
Show file tree
Hide file tree
Showing 29 changed files with 955 additions and 1,223 deletions.
27 changes: 13 additions & 14 deletions dpx/src/dpx_bmpimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use super::dpx_mem::new;
use super::dpx_numbers::tt_get_unsigned_byte;
use super::dpx_pdfximage::{pdf_ximage_init_image_info, pdf_ximage_set_image};
use crate::dpx_pdfobj::{
pdf_add_array, pdf_add_dict, pdf_add_stream, pdf_new_array, pdf_new_name, pdf_new_number,
pdf_new_name, pdf_new_number, IntoObj,
pdf_new_stream, pdf_new_string, pdf_release_obj,
pdf_stream_set_predictor, STREAM_COMPRESS,
};
Expand Down Expand Up @@ -135,7 +135,6 @@ pub unsafe fn bmp_include_image(
};
let num_palette;
pdf_ximage_init_image_info(&mut info);
let colorspace;
handle.seek(SeekFrom::Start(0)).unwrap();
if read_header(handle, &mut hdr) < 0i32 {
return -1i32;
Expand Down Expand Up @@ -187,7 +186,7 @@ pub unsafe fn bmp_include_image(
let stream = pdf_new_stream(STREAM_COMPRESS);
let stream_dict = (*stream).as_stream_mut().get_dict_mut();
/* Color space: Indexed or DeviceRGB */
if (hdr.bit_count as i32) < 24i32 {
let colorspace = if (hdr.bit_count as i32) < 24i32 {
let mut bgrq: [u8; 4] = [0; 4];
let palette = new(((num_palette * 3i32 + 1i32) as u32 as u64)
.wrapping_mul(::std::mem::size_of::<u8>() as u64) as u32) as *mut u8;
Expand All @@ -209,15 +208,16 @@ pub unsafe fn bmp_include_image(
(num_palette * 3i32) as size_t,
);
free(palette as *mut libc::c_void);
colorspace = pdf_new_array();
pdf_add_array(&mut *colorspace, pdf_new_name("Indexed"));
pdf_add_array(&mut *colorspace, pdf_new_name("DeviceRGB"));
pdf_add_array(&mut *colorspace, pdf_new_number((num_palette - 1i32) as f64));
pdf_add_array(&mut *colorspace, lookup);
let mut colorspace = vec![];
colorspace.push(pdf_new_name("Indexed"));
colorspace.push(pdf_new_name("DeviceRGB"));
colorspace.push(pdf_new_number((num_palette - 1i32) as f64));
colorspace.push(lookup);
colorspace.into_obj()
} else {
colorspace = pdf_new_name("DeviceRGB")
}
pdf_add_dict(stream_dict, "ColorSpace", colorspace);
pdf_new_name("DeviceRGB")
};
stream_dict.set("ColorSpace", colorspace);
/* Raster data of BMP is four-byte aligned. */
let stream_data_ptr;
let mut rowbytes = (info.width * hdr.bit_count as i32 + 7i32) / 8i32;
Expand Down Expand Up @@ -287,12 +287,11 @@ pub unsafe fn bmp_include_image(
let mut n = info.height - 1i32;
while n >= 0i32 {
let p = stream_data_ptr.offset((n * rowbytes) as isize);
pdf_add_stream(&mut *stream, p as *const libc::c_void, rowbytes);
(*stream).as_stream_mut().add(p as *const libc::c_void, rowbytes);
n -= 1
}
} else {
pdf_add_stream(
&mut *stream,
(*stream).as_stream_mut().add(
stream_data_ptr as *const libc::c_void,
rowbytes * info.height,
);
Expand Down
10 changes: 5 additions & 5 deletions dpx/src/dpx_cid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use super::dpx_cidtype2::{
};
use super::dpx_mem::{new, renew};
use crate::dpx_pdfobj::{
pdf_add_dict, pdf_copy_name, pdf_get_version, pdf_link_obj,
pdf_copy_name, pdf_get_version, pdf_link_obj,
pdf_name_value, pdf_new_name, pdf_number_value, pdf_obj, pdf_ref_obj,
pdf_release_obj, pdf_remove_dict, pdf_string_value,
};
Expand Down Expand Up @@ -847,10 +847,10 @@ unsafe fn CIDFont_base_open(
pdf_remove_dict(&mut *fontdict, "W2");
}
}
pdf_add_dict(&mut *fontdict, "Type", pdf_new_name("Font"));
pdf_add_dict(&mut *fontdict, "BaseFont", pdf_copy_name(fontname));
pdf_add_dict(&mut *descriptor, "Type", pdf_new_name("FontDescriptor"));
pdf_add_dict(&mut *descriptor, "FontName", pdf_copy_name(fontname));
(*fontdict).as_dict_mut().set("Type", pdf_new_name("Font"));
(*fontdict).as_dict_mut().set("BaseFont", pdf_copy_name(fontname));
(*descriptor).as_dict_mut().set("Type", pdf_new_name("FontDescriptor"));
(*descriptor).as_dict_mut().set("FontName", pdf_copy_name(fontname));
(*font).fontdict = fontdict;
(*font).descriptor = descriptor;
(*opt).embed = 0i32;
Expand Down
Loading

0 comments on commit 7cd148e

Please sign in to comment.