From 2d512cc8ed40c04a423b4bcee7fa338456ac7a1f Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sun, 19 Mar 2023 19:58:15 +0000 Subject: [PATCH] more --- cpdfpng.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cpdfpng.ml b/cpdfpng.ml index 7955b42..67c9a3b 100644 --- a/cpdfpng.ml +++ b/cpdfpng.ml @@ -47,7 +47,7 @@ let write_crc o ctype cdata = o.output_byte d let write_chunk o ctype data = - for x = 0 to 4 do o.output_byte (int_of_char ctype.[x]) done; + for x = 0 to 3 do o.output_byte (int_of_char ctype.[x]) done; o.output_string (Bytes.unsafe_to_string data); write_crc o ctype (Bytes.unsafe_to_string data) @@ -137,6 +137,11 @@ let read_png i = with _ -> () end; - {width = i32toi width; height = i32toi height; idat = concat_bytes (rev !idat)} + let r = + {width = i32toi width; height = i32toi height; idat = concat_bytes (rev !idat)} + in + let ch = open_out_bin "out.png" in + write_png r (Pdfio.output_of_channel ch); + r with e -> raise (Pdf.PDFError (Printf.sprintf "read_png: failed on %s" (Printexc.to_string e)))