1
(***********************************************************************)
5
(* Fran�ois Pessaux, projet Cristal, INRIA Rocquencourt *)
6
(* Pierre Weis, projet Cristal, INRIA Rocquencourt *)
7
(* Jun Furuse, projet Cristal, INRIA Rocquencourt *)
9
(* Copyright 1999-2004, *)
10
(* Institut National de Recherche en Informatique et en Automatique. *)
11
(* Distributed only by permission. *)
13
(***********************************************************************)
15
(* $Id: cmyk32.ml,v 1.1 2006/11/28 15:43:28 rousse Exp $*)
17
(* CMYK 32 bit depth image format *)
22
let bytes_per_pixel = 4
24
{ c = int_of_char str.[pos ];
25
m = int_of_char str.[pos + 1];
26
y = int_of_char str.[pos + 2];
27
k = int_of_char str.[pos + 3]; }
29
str.[pos ] <- char_of_int t.c;
30
str.[pos + 1] <- char_of_int t.m;
31
str.[pos + 2] <- char_of_int t.y;
32
str.[pos + 3] <- char_of_int t.k
34
let str = String.create bytes_per_pixel in
39
module RI = Genimage.MakeRawImage(E);;
41
type rawimage = RI.t;;
42
type elt = Color.cmyk;;
47
mutable infos : Info.info list;
53
let rawimage x = x.rawimage
54
let create_default width height rawimage =
59
let create_duplicate src width height rawimage =
66
module IMAGE = Genimage.Make(RI)(C);;
68
let create_with width height infos data =
71
rawimage = RI.create_with width height data;
74
let rawimage = C.rawimage;;
75
let create = IMAGE.create;;
76
let make = IMAGE.make;;
77
let dump = IMAGE.dump;;
78
let unsafe_access = IMAGE.unsafe_access;;
79
let get_strip = IMAGE.get_strip;;
80
let set_strip = IMAGE.set_strip;;
81
let get_scanline = IMAGE.get_scanline;;
82
let set_scanline = IMAGE.set_scanline;;
83
let unsafe_get = IMAGE.unsafe_get;;
84
let unsafe_set = IMAGE.unsafe_set;;
87
let destroy = IMAGE.destroy;;
88
let copy = IMAGE.copy;;
90
let blit = IMAGE.blit;;
95
(* image resize with smoothing *)
96
let resize prog img nw nh =
97
let newimage = create nw nh in
98
let xscale = float nw /. float img.width in
99
let yscale = float nh /. float img.height in
100
for y = 0 to nh - 1 do
101
for x = 0 to nw - 1 do
102
let start_x = truncate (float x /. xscale)
103
and start_y = truncate (float y /. yscale)
105
let end_x = truncate ((float x +. 0.99) /. xscale)
106
and end_y = truncate ((float y +. 0.99) /. yscale) in
107
let size = (end_x - start_x + 1) * (end_y - start_y + 1) in
112
for xx = start_x to end_x do
113
for yy = start_y to end_y do
114
let c = unsafe_get img xx yy in
121
unsafe_set newimage x y
128
| Some p -> p (float (y + 1) /. float nh)