FishEye.xs

filter: Statementstmt 5.5% 1 / 18 Branchbran 15.0% 3 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 10.5% 4 / 38 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Imager/Filter/FishEye.pm ↑ Summary
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7 #include "ppport.h"
8 #ifdef __cplusplus
9 }
10 #endif
11  
12 #include <math.h>
13 #include "imext.h"
14 #include "imperl.h"
15  
16 #define min(x,y) ((x)<(y) ? (x) : (y))
17  
18 void
19 0 __fisheye(i_img *im, double r, double d) {
20 i_color color;
21 i_img *canvas;
22  
23 int x,y;
24 int xx, yy;
25  
26 0 ▶ if (r == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) { 0 0 0
27 0 r = min(im->xsize, im->ysize)/2;
28 }
29 0 int w = im->xsize;
30 0 int h = im->ysize;
31  
32 0 canvas = i_img_8_new(im->xsize, im->ysize, im->channels);
33  
34 0 ▶ for(x = 0; x < im->xsize; ++x) {
Branch: 1 branch
BranchTrueFalseTotal
for(x = 0; x < im->xsize; ++x) { 0 0 0
35 0 ▶ for(y = 0; y < im->ysize; ++y) {
Branch: 1 branch
BranchTrueFalseTotal
for(y = 0; y < im->ysize; ++y) { 0 0 0
36 0 double rp = sqrt(d*d + (x-w/2)*(x-w/2) + (y-h/2)*(y-h/2));
37 0 xx = rp*(x-w/2)/r + w/2;
38 0 yy = rp*(y-h/2)/r + h/2;
39 0 ▶ if (xx>=0 && xx<w && yy>=0 && yy<h) {
Branch: 4 branches
BranchTrueFalseTotal
if (xx>=0 && xx<w && yy>=0 && yy<h) { 0 0 0
if (xx>=0 && xx<w && yy>=0 && yy<h) { 0 0 0
if (xx>=0 && xx<w && yy>=0 && yy<h) { 0 0 0
if (xx>=0 && xx<w && yy>=0 && yy<h) { 0 0 0
40 0 i_gpix(im, xx, yy, &color);
41 0 i_ppix(canvas, x, y, &color);
42 }
43 }
44 }
45 0 i_copyto(im, canvas, 0, 0, (int)im->xsize, (int)im->ysize, 0, 0);
46 0 i_img_destroy(canvas);
47 0 }
48  
49 DEFINE_IMAGER_CALLBACKS;
50  
51 MODULE = Imager::Filter::FishEye PACKAGE = Imager::Filter::FishEye
52  
53 PROTOTYPES: ENABLE
54  
55 void
56 __fisheye(im, r, d)
57 Imager::ImgRaw im
58 int r
59 int d
60  
61 BOOT:
62 1 ▶ PERL_INITIALIZE_IMAGER_CALLBACKS;
Branch: 3 branches
BranchTrueFalseTotal
PERL_INITIALIZE_IMAGER_CALLBACKS; 0 1 1
PERL_INITIALIZE_IMAGER_CALLBACKS; 0 1 1
PERL_INITIALIZE_IMAGER_CALLBACKS; 0 1 1
63  
« blib/lib/Imager/Filter/FishEye.pm ↑ Summary