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 FvsString_t filename
)
38 ExceptionInfo exception
;
42 FvsError_t ret
= FvsOK
;
49 /* Init Magick environment */
50 MagickCoreGenesis(".",MagickFalse
);
51 GetExceptionInfo(&exception
);
53 /* Create an empty imageinfo */
54 magicinfo
= CloneImageInfo((ImageInfo
*)NULL
);
56 /* set the filename */
57 (void)strcpy(magicinfo
->filename
, filename
);
60 magicimage
= ReadImage(magicinfo
, &exception
);
61 if (exception
.severity
!=UndefinedException
)
62 CatchException(&exception
);
63 if (magicimage
!=(Image
*)NULL
)
65 /* dump info for debugging purposes at the moment */
66 /* DescribeImage(magicimage, stdout, 0); */
68 /* allocate the image for Fvs */
69 ret
= ImageSetSize(image
,
70 (FvsInt_t
)magicimage
->columns
,
71 (FvsInt_t
)magicimage
->rows
);
74 /* get buffer and pitch */
75 buffer
= ImageGetBuffer(image
);
76 pitch
= ImageGetPitch(image
);
77 height
= ImageGetHeight(image
);
78 width
= ImageGetWidth(image
);
80 /* set image type and normalize */
81 NormalizeImage(magicimage
);
84 for (i
=0; i
<height
; i
++)
86 ExportImagePixels(magicimage
, 0, i
, width
, 1, "I", CharPixel
,
87 buffer
+i
*pitch
, &exception
);
90 DestroyImage(magicimage
);
96 DestroyImageInfo(magicinfo
);
97 DestroyExceptionInfo(&exception
);