Skip to content

Commit 73a31f8

Browse files
authored
make corrections (#122)
1 parent ee58c1e commit 73a31f8

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

mupdf-sys/wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ fz_rect mupdf_bound_page(fz_context *ctx, fz_page *page, mupdf_error_t **errptr)
722722
return rect;
723723
}
724724

725-
fz_pixmap *mupdf_page_to_pixmap(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, float alpha, bool show_extras, mupdf_error_t **errptr)
725+
fz_pixmap *mupdf_page_to_pixmap(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, bool alpha, bool show_extras, mupdf_error_t **errptr)
726726
{
727727
fz_pixmap *pixmap = NULL;
728728
fz_try(ctx)

src/document.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,21 @@ impl Document {
5656
Self { inner: ptr }
5757
}
5858

59-
pub fn open(filename: &str) -> Result<Self, Error> {
60-
let c_name = CString::new(filename)?;
59+
pub fn open<P: AsRef<std::path::Path>>(p: P) -> Result<Self, Error> {
60+
// Must be UTF8 on Windows
61+
#[cfg(windows)]
62+
let raw = match <&str>::try_from(p.as_ref().as_os_str()) {
63+
Ok(s) => s,
64+
Err(e) => {
65+
use std::io::{self, ErrorKind};
66+
let err = Error::Io(io::Error::new(ErrorKind::Other, e));
67+
return Err(err);
68+
}
69+
};
70+
71+
#[cfg(not(windows))]
72+
let raw = p.as_ref().as_os_str().as_encoded_bytes();
73+
let c_name = CString::new(raw)?;
6174
unsafe { ffi_try!(mupdf_open_document(context(), c_name.as_ptr())) }
6275
.map(|inner| Self { inner })
6376
}

src/page.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Page {
5050
&self,
5151
ctm: &Matrix,
5252
cs: &Colorspace,
53-
alpha: f32,
53+
alpha: bool,
5454
show_extras: bool,
5555
) -> Result<Pixmap, Error> {
5656
unsafe {

tests/test_issues.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn test_issue_16_pixmap_to_png() {
88
let page = document.load_page(0).unwrap();
99
let matrix = Matrix::new_scale(72f32 / 72f32, 72f32 / 72f32);
1010
let pixmap = page
11-
.to_pixmap(&matrix, &Colorspace::device_rgb(), 0.0, true)
11+
.to_pixmap(&matrix, &Colorspace::device_rgb(), false, true)
1212
.unwrap();
1313
pixmap
1414
.save_as("tests/output/test.png", ImageFormat::PNG)

0 commit comments

Comments
 (0)