-
Notifications
You must be signed in to change notification settings - Fork 1
/
util_main.c
85 lines (67 loc) · 1.77 KB
/
util_main.c
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
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
#include "ft9201.h"
#include <math.h>
#include <wand/magick_wand.h>
void raw_wand(void)
{
MagickWand *mw = NULL;
MagickWandGenesis();
mw=NewMagickWand();
MagickReadImage(mw,"img.raw");
char *data = (char*)malloc(sizeof(char) * 20480);
MagickConstituteImage(mw,80,64,"rgb",CharPixel,data);
//MagickImportImagePixels(mw,80,64,80,64,"I",CharPixel,data);
//MagickGetImagePixels(mw,80,64,80,64,"I",CharPixel,data);
//MagickQuantizeImage(mw,256,GRAYColorspace,0,MagickFalse,MagickFalse);
//MagickSetImageType(mw, GrayscaleType);
//MagickSetImageDepth(mw, 8);
//MagickSetImageColorspace(mw,GRAYColorspace);
//MagickTransformImageColorspace(mw, GRAYColorspace);
//MagickSetImageDepth(mw, 8);
MagickWriteImage(mw,"finger.png");
if(mw)mw = DestroyMagickWand(mw);
MagickWandTerminus();
}
int main(int argc, char *argv[]) {
unsigned int action = 0;
printf("FT9201 utility program\n");
if (argc < 2) {
fprintf(stderr, "Usage: %s <device_file> [action]\n", argv[0]);
return -1;
}
if (argc == 3) {
action = (unsigned int) atoi(argv[2]);
}
printf("Action: %d\n", action);
char *device_file_name = argv[1];
struct ft9201_status device_status;
printf("Device: %s\n", device_file_name);
if (action == 0) {
fprintf(stderr, "status struct: %p\n", &device_status);
int result;
printf("Initializing device\n");
} else if (action == 1) {
printf("Reading\n");
int fd;
char buff[5120];
fd = open(device_file_name,O_RDONLY);
if (fd != -1) {
read(fd,buff,5120);
close(fd);
}
int sdfd;
sdfd = open("img.raw",O_WRONLY | O_CREAT);
if (sdfd == -1) {
printf("bad open\n");
exit(-1);
}
write(sdfd,buff,(5120));
close(sdfd);
}
raw_wand();
return 0;
}