Speed up dumping of PNM files
This commit is contained in:
parent
0857e8ab0c
commit
5480a08e77
28
cpdfimage.ml
28
cpdfimage.ml
|
@ -20,26 +20,14 @@ let pnm_to_channel_24 ch w h s =
|
||||||
pnm_header ch w h;
|
pnm_header ch w h;
|
||||||
pnm_output_string ch "255";
|
pnm_output_string ch "255";
|
||||||
pnm_newline ch;
|
pnm_newline ch;
|
||||||
let pos = ref 0 in
|
bytes_to_output_channel ch s
|
||||||
for y = 1 to h do
|
|
||||||
for x = 1 to w * 3 do
|
|
||||||
output_byte ch (bget s !pos);
|
|
||||||
incr pos
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
let pnm_to_channel_8 ch w h s =
|
let pnm_to_channel_8 ch w h s =
|
||||||
pnm_output_string ch "P5";
|
pnm_output_string ch "P5";
|
||||||
pnm_header ch w h;
|
pnm_header ch w h;
|
||||||
pnm_output_string ch "255";
|
pnm_output_string ch "255";
|
||||||
pnm_newline ch;
|
pnm_newline ch;
|
||||||
let pos = ref 0 in
|
bytes_to_output_channel ch s
|
||||||
for y = 1 to h do
|
|
||||||
for x = 1 to w do
|
|
||||||
output_byte ch (bget s !pos);
|
|
||||||
incr pos
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
let pnm_to_channel_1_inverted ch w h s =
|
let pnm_to_channel_1_inverted ch w h s =
|
||||||
pnm_output_string ch "P4";
|
pnm_output_string ch "P4";
|
||||||
|
@ -47,16 +35,12 @@ let pnm_to_channel_1_inverted ch w h s =
|
||||||
pnm_newline ch;
|
pnm_newline ch;
|
||||||
let inverted = Pdfio.copybytes s in
|
let inverted = Pdfio.copybytes s in
|
||||||
Pdfio.bytes_selfmap lnot inverted;
|
Pdfio.bytes_selfmap lnot inverted;
|
||||||
pnm_output_string ch (Pdfio.string_of_bytes inverted)
|
bytes_to_output_channel ch inverted
|
||||||
|
|
||||||
let cmyk_to_channel_32 ch w h s =
|
let cmyk_to_channel_32 ch w h s =
|
||||||
let pos = ref 0 in
|
let inverted = Pdfio.copybytes s in
|
||||||
for y = 1 to h do
|
Pdfio.bytes_selfmap (fun x -> 255 - x) inverted;
|
||||||
for x = 1 to w * 4 do
|
bytes_to_output_channel ch inverted
|
||||||
output_byte ch (255 - bget s !pos);
|
|
||||||
incr pos
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
let jbig2_serial = ref 0
|
let jbig2_serial = ref 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue