Similar.xs

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 39 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Image/Similar.pm ↑ Summary similar-image.c »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include "ppport.h"
5  
6 #include "similar-image.h"
7  
8 #define SIMAGE_CALL(x) { \
9 simage_status_t status; \
10 status = x; \
11 if (status != simage_ok) { \
12 croak ("error %d from similar-image library", status); \
13 } \
14 }
15  
16 typedef simage_t * Image__Similar__Image;
17  
18 /* This defines "Image::Similar::Image", which is a part of an
19 Image::Similar object, labelled like $is->{image}. */
20  
21 MODULE=Image::Similar PACKAGE=Image::Similar::Image
22  
23 PROTOTYPES: DISABLE
24  
25 Image::Similar::Image
26 isnew (width, height);
27 int width;
28 int height;
29 CODE:
30 0 Newxz (RETVAL, 1, simage_t);
31 0 ▶ SIMAGE_CALL (simage_init (RETVAL, width, height));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_init (RETVAL, width, height)); 0 0 0
32 OUTPUT:
33 RETVAL
34  
35 void
36 DESTROY (image)
37 Image::Similar::Image image;
38 CODE:
39 0 ▶ SIMAGE_CALL (simage_free (image));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_free (image)); 0 0 0
40 0 Safefree (image);
41  
42 void
43 set_pixel (image, x, y, grey)
44 Image::Similar::Image image
45 int x
46 int y
47 unsigned char grey
48 CODE:
49 //printf ("%d %d\n", x, y);
50 0 ▶ SIMAGE_CALL (simage_set_pixel (image, x, y, grey));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_set_pixel (image, x, y, grey)); 0 0 0
51  
52 AV *
53 get_rows (image)
54 Image::Similar::Image image
55 PREINIT:
56 int y;
57 CODE:
58 0 RETVAL = newAV ();
59 0 ▶ for (y = 0; y < image->height; y++) {
Branch: 1 branch
BranchTrueFalseTotal
for (y = 0; y < image->height; y++) { 0 0 0
60 //printf ("%d\n", y);
61 0 av_push (RETVAL, newSVpv ((const char *) image->data + y * image->width, image->width));
62 }
63 OUTPUT:
64 RETVAL
65  
66 void
67 fill_grid (image)
68 Image::Similar::Image image
69 CODE:
70 0 ▶ SIMAGE_CALL (simage_fill_grid (image));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_fill_grid (image)); 0 0 0
71  
72 Image::Similar::Image
73 fill_from_sig (sig)
74 SV * sig;
75 PREINIT:
76 char * signature;
77 STRLEN signature_length;
78 CODE:
79 0 Newxz (RETVAL, 1, simage_t);
80 0 signature = SvPV (sig, signature_length);
81 0 ▶ SIMAGE_CALL (simage_fill_from_signature (RETVAL, signature,
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_fill_from_signature (RETVAL, signature, 0 0 0
82 (int) signature_length));
83 OUTPUT:
84 RETVAL
85  
86 double
87 image_diff (image1, image2)
88 Image::Similar::Image image1
89 Image::Similar::Image image2
90 CODE:
91 0 ▶ SIMAGE_CALL (simage_diff (image1, image2, & RETVAL));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_diff (image1, image2, & RETVAL)); 0 0 0
92 OUTPUT:
93 RETVAL
94  
95 SV *
96 signature (image)
97 Image::Similar::Image image
98 CODE:
99 0 ▶ if (! image->signature) {
Branch: 1 branch
BranchTrueFalseTotal
if (! image->signature) { 0 0 0
100 0 ▶ SIMAGE_CALL (simage_signature (image));
Branch: 1 branch
BranchTrueFalseTotal
SIMAGE_CALL (simage_signature (image)); 0 0 0
101 }
102 0 RETVAL = newSVpv (image->signature, (STRLEN) image->signature_length);
103 OUTPUT:
104 RETVAL
105  
106 SV *
107 valid_image (image)
108 Image::Similar::Image image
109 CODE:
110 0 ▶ if (image->valid_image) {
Branch: 1 branch
BranchTrueFalseTotal
if (image->valid_image) { 0 0 0
111 0 RETVAL = & PL_sv_yes;
112 }
113 else {
114 0 RETVAL = & PL_sv_no;
115 }
116 OUTPUT:
117 RETVAL
118  
« blib/lib/Image/Similar.pm ↑ Summary similar-image.c »