File: Flines.xs

package info (click to toggle)
libimager-perl 1.000%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,204 kB
  • ctags: 4,002
  • sloc: perl: 30,288; ansic: 27,490; sh: 51; makefile: 48; cpp: 4
file content (62 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (8)
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
#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#ifdef __cplusplus
}
#endif

#include "imext.h"
#include "imperl.h"

unsigned char
static
saturate(int in) {
  if (in>255) { return 255; }
  else if (in>0) return in;
  return 0;
}

static void
flines(i_img *im) {
  i_color vl;
  i_img_dim x,y;

  for(y = 0; y < im->ysize; y ++) {
    float yf, mf;
    if (!(y%2)) {
      yf = y/(double)im->ysize;
    }
    else {
      yf = (im->ysize-y)/(double)im->ysize;
    }
    mf = 1.2-0.8*yf;

    for(x = 0; x < im->xsize; x ++ ) {
      i_gpix(im,x,y,&vl); 
      vl.rgb.r = saturate(vl.rgb.r*mf);
      vl.rgb.g = saturate(vl.rgb.g*mf);
      vl.rgb.b = saturate(vl.rgb.b*mf);
      i_ppix(im,x,y,&vl);
    }
  }
}


DEFINE_IMAGER_CALLBACKS;

MODULE = Imager::Filter::Flines   PACKAGE = Imager::Filter::Flines

PROTOTYPES: ENABLE

void
flines(im)
        Imager::ImgRaw im

BOOT:
        PERL_INITIALIZE_IMAGER_CALLBACKS;