1 /*########################################################################
3 The contents of this file are subject to the Mozilla Public License
4 Version 1.0(the "License"); You may NOT use this file except in
5 compliance with the License. You may obtain a copy of the License at
6 http:// www.mozilla.org/MPL/
7 Software distributed under the License is distributed on an "AS IS"
8 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 the License for the specific language governing rights and limitations
12 The Initial Developer of the Original Code is Shivang Patel.
14 Copyright(C) 2002. All Rights Reserved.
16 Authors: Shivang Patel
20 Changes: jdh -> Added support for ImageMagick that enables
21 to import files from more than 40 formats.
22 mw -> Removed deprecated, adapted for dvp lu.
24 ########################################################################*/
31 #include <magick/api.h>
35 /* imports a fingeprint image from a file */
36 FvsError_t
FvsImageImport(FvsImage_t image
, const char *filename
)
38 ExceptionInfo exception
;
42 FvsError_t ret
= FvsOK
;
49 /* Init Magick environment */
52 MagickCoreGenesis(".",MagickFalse
);
53 GetExceptionInfo(&exception
);
55 /* Create an empty imageinfo */
56 magicinfo
= CloneImageInfo((ImageInfo
*)NULL
);
58 /* set the filename */
59 (void)strcpy(magicinfo
->filename
, filename
);
62 magicimage
= ReadImage(magicinfo
, &exception
);
63 if (exception
.severity
!=UndefinedException
)
64 CatchException(&exception
);
65 if (magicimage
!=(Image
*)NULL
)
67 /* dump info for debugging purposes at the moment */
68 /* DescribeImage(magicimage, stdout, 0); */
70 /* allocate the image for Fvs */
71 ret
= ImageSetSize(image
,
72 (FvsInt_t
)magicimage
->columns
,
73 (FvsInt_t
)magicimage
->rows
);
76 /* get buffer and pitch */
77 buffer
= ImageGetBuffer(image
);
78 pitch
= ImageGetPitch(image
);
79 height
= ImageGetHeight(image
);
80 width
= ImageGetWidth(image
);
82 /* set image type and normalize */
83 NormalizeImage(magicimage
);
86 for (i
=0; i
<height
; i
++)
88 ExportImagePixels(magicimage
, 0, i
, width
, 1, "I", CharPixel
,
89 buffer
+i
*pitch
, &exception
);
92 DestroyImage(magicimage
);
98 DestroyImageInfo(magicinfo
);
99 DestroyExceptionInfo(&exception
);
100 MagickCoreTerminus();