File: eng.htm

package info (click to toggle)
camlimages 2.20-8
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 4,016 kB
  • ctags: 2,436
  • sloc: ml: 12,244; ansic: 2,402; makefile: 1,148; sh: 203
file content (238 lines) | stat: -rw-r--r-- 9,153 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 "http://www.w3.org/TR/REC-html40/loose.dtd">

<HTML>

<HEAD>
<TITLE>CamlImages</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

<P>Contact the authors <EM><A
HREF="mailto:Jun.Furuse@inria.fr">Jun.Furuse@inria.fr</A></EM> and
<EM><A HREF="mailto:Pierre.Weis@inria.fr">Pierre.Weis@inria.fr</A></EM>.

<BR>Created the 7th of February 2000.
<BR>Last update on Fri Oct 1 2004.

<H1 ALIGN=CENTER>CamlImages</H1>
<H2 ALIGN=CENTER>Version 2.2</H2>
<center><img src="fumicaml2-small.jpg"></center>

<H2 ALIGN=CENTER>Objective Caml image processing library</H2>

<P>
<EM>Note: this library is currently(=always) under development.</EM>

<center>
<a href="test.jpg"><img src="test-small.jpg"></a>
</center>

<H2 ALIGN=LEFT>0. What is CamlImages ?</H2>

<P> CamlImages is an image processing library, which provides

<UL>
 <LI>Basic functions for image processing and loading/saving various image
file formats (hence providing a translation facility from format to format),
 <LI>An interface with the Caml graphics library allows to display
images in the Graphics module screen and to mix them with Caml
drawings,
 <LI>A <CODE>freetype</CODE> interface, integrated into the library:
you can draw texts into images using any <EM>truetype</EM> fonts.
</UL>

<P>In addition, the library can handle huge images that
cannot be (or can hardly be) stored into the main memory (the library
then automatically creates swap files and escapes them to reduce the
memory usage).

<P>Additional example programs are supplied in the
<CODE>examples</CODE> directory of the library:
<DL>
 <DT><CODE>converter</CODE>:
 <DD>a convertion program, that converts image from formats to formats.

 <DT><CODE>crop</CODE>:
 <DD>a ``cropping'' program, that cuts an image to its edges.<br> 
 <a href="crop.jpg"><img src="crop-icon.jpg"></A>

 <DT><CODE>edgedetect</CODE>:
 <DD>a program to detect edges into an image.<br>
 <a href="edge.jpg"><img src="edge-icon.jpg"></A>

 <DT> <CODE>gifanim</CODE>:
 <DD>an animation program for <CODE>gif</CODE> encoded series of images.

 <DT><CODE>liv</CODE>:
 <DD>an extension of the Unix <CODE>ls</CODE> command
 to view a set of images. (Also considered as a light version of
<CODE>xv</CODE> with nice slide show capabilities.)<br>
 <a href="lvdemo.jpg"><img src="lvdemo-icon.jpg"></A>

 <DT><CODE>monochrome</CODE>:
 <DD>converts a color image to monochrome.

 <DT><CODE>normalize</CODE>:
 <DD>normalizes the colormap of an image. This
program anlyzes the colormap information of the image to normalize its
brightness over the full range available.

 <DT><CODE>resize</CODE>:
 <DD>a program to resize an image.

 <DT><CODE>tiffps</CODE>:
 <DD>a program to output a postscript version of a tiff image (for
instance to print it).

 <DT><CODE>ttfimg</CODE>:
 <DD>true type font dump program. It can be used to create fancy
banners or buttons.<br>
Try for instance <TT>ttfimg ../../test/micap.ttf -message Bonjour -fg red -bg
black</TT>. Visualize with <CODE>liv</CODE> (of course).
<CODE>ttfimg</CODE> also creates some sample images of true type fonts.
Try <TT>ttfimg -o sample_micap.jpg ../../test/micap.ttf</TT>.<br>
<a href="ttfimg.jpg"><img src="ttfimg-icon.jpg"></A>
</DL>


<H2 ALIGN=LEFT>1. Installation</H2>

<P>Get the <A HREF=
"ftp://ftp.inria.fr/INRIA/Projects/cristal/caml-light/bazar-ocaml/camlimages-2.2.0.tgz">source
tar ball</A>, decompress it,
and read the file <CODE><A HREF="INSTALL">INSTALL</A></CODE>.
<BR>You can also access the read-only 
<A HREF="http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/bazar-ocaml/camlimages/">
CVS repository</A> which contains the latest developing (but not yet
released) version.

<H2 ALIGN=LEFT>2. Using CamlImages</H2>

<H3 ALIGN=LEFT>2.1 Color models</H3>
<P>CamlImages supports the following color models:

<UL>
  <LI><CODE>Rgb24</CODE>: 24bit depth full color image.
  <LI><CODE>Index8</CODE>: 8bit depth indexed image with transparent
information.
  <LI><CODE>Index16</CODE>: 16bit depth indexed image with transparent.
  <LI><CODE>Rgba32</CODE>: 32bit depth full color image, with the alpha channel.
  <LI><CODE>Cmyk32</CODE>: 32bit Cyan Magenta Yellow and blacK image.
  (Unfortunatelly, beautiful conversion between RGB and CMYK is not supported.)
</UL>

For each color model, a corresponding module is provided. For example,
use the module <CODE>Rgb24</CODE> if you want to access 24bit depth
full color images.

<H3 ALIGN=LEFT>2.2 Load/Save image files and other fancy features</H3>

<P>CamlImages supports loading and saving of the following file formats:

<UL>
  <LI>Bitmap, windows bitmap format (.bmp).
  <LI>Gif, graphics interchange format (.gif) (not recommended).
  <LI>Jpeg, joint photographic experts group (.jpeg or .jpg).
  <LI>Png, portable network graphics (.png).
  <LI>Tiff, tagged image file format (.tiff or .tif). (Color only.) 
  <LI>X pixmaps (.xpm). (Loading only.)
  <LI>Encapsulated Postscript (using ghostscript)
  <LI>xv thumbnail files (see xvthumb directory).
</UL>

<P>For each image format, we provide a separate module. For instance,
use the <CODE>Tiff</CODE> module to load and save images stored in the tiff file
format.

<BR>If you do not want to specify the file format, you can use
<CODE>Image.load</CODE>: this function automatically analyses the
header of the image file at hand and loads the image into the memory,
if the library supports this format.

<P>CamlImages also provides an interface to the internal image format of
O'Caml's Graphics library (this way you can draw your image files into 
the Graphics window).

<P>You can also draw strings on images using the Freetype library, which 
is an external library to load and render TrueType fonts.

<H3 ALIGN=LEFT>2.3 Class interface</H3>

<P>The modules with names beginning with the letter 'o' contains the object
class interface for CamlImages.

<H3 ALIGN=LEFT>2.4 Image swap</H3>

<P> When you create/load a huge image, the computer memory may not be
sufficient to contain all the data. (For example, this may happen if
you are working with a scanned image of A4, 720dpi, 24bit fullcolor,
even if you have up to 128Mb of memory!) To work with such huge
images, CamlImages provides image swaps, which can escape part of the
images into files stored on the hard disk. A huge image is thus
partitioned into several blocks and if there is not enough free
memory, the blocks which have not been accessed recently are swapped
to temporary files.  If a program requests to access to such a swapped
block, the library silently loads it back into memory.

<BR> By default, image swapping is disabled, because it slows down the
programs. To activate this function, you have to modify
<CODE>Bitmap.maximum_live</CODE> and
<CODE>Bitmap.maximum_block_size</CODE>:
<UL>
 <LI><CODE>Bitmap.maximum_live</CODE>
is the maximum heap live data size of the program (in words)
 <LI><CODE>Bitmap.maximum_block_size</CODE> is the maximum size of swap
blocks (in words).
</UL>

<BR> For example, if you do not want to use more than 10M words (that
is 40Mb for a 32bit architecture or 80Mb for a 64bit architecture),
set Bitmap.maximum_live to 10000000. You may (and you should) enable
heap compaction, look at the GC interface file, <CODE>gc.mli</CODE>, in the
standard library for more details (you should change the compaction
configuration).

<BR><CODE>Bitmap.maximum_block_size</CODE> affects the speed and frequency of
image block swapping. If it is larger, each swapping becomes
slower. If it is smaller, more swappings will occur. Too large and too
small <CODE>maximum_block_size</CODE>, both may make the program
slower. I suggest to have maximum_block_size set to
<CODE>!Bitmap.maximum_live / 10</CODE>. 

<BR>If you activated image swapping, cache files for unused swapped 
blocks will be removed automatically by Caml GC finalization, 
but you may free them explicitly by hand also. The functions and methods 
named "destroy" will free those blocks. 

<BR>The swap files are usually created in the <CODE>/tmp</CODE>
directory. If you set the environment variable
<CODE>"CAMLIMAGESTMPDIR"</CODE>, then its value replaces the default
<CODE>"/tmp"</CODE> directory. The temporary files are erased when the
program exits successfully. In other situations, for instance in case
of spurious exception, you may need to erase temporary files manually.

<H2 ALIGN=LEFT>3. Miscellaneous</H2>

<H3 ALIGN=LEFT>3.1 Examples of use of the library ?</H3>

You can find some examples in the <CODE>examples</CODE> directory including
image auto-cropping, resizing and an image viewer with the lablgtk library.

<H3 ALIGN=LEFT>3.2 How do I organize my Makefile to use the library ?</H3>

Put the following line at the top of your Makefile:
<PRE>
	include /usr/local/lib/ocaml/camlimages/Makefile.config
</PRE>

The library directory can be different, if the library is installed
somewhere else. The variables <CODE>COMPFLAGS_CAMLIMAGES</CODE> and
<CODE>LINKFLAGS_CAMLIMAGES</CODE> are defined in
<CODE>Makefile.config</CODE>; you should add them to the compiler and
linker options. A sample Makefile is available as
<CODE>sample/Makefile.sample</CODE>.

</BODY>
</HTML>