summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/imageviewer/imageviewer.js
blob: f69d63c3ae62ae88993858915baa9767e38cb31f (plain)
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
#!/usr/bin/env kjscmd

// Applies a water color effect filter to the image
function apply_watercolor( img )
{
    var imgfx = new ImageFX();
    img = imgfx.contrast(img, 200);
    img = imgfx.despeckle(img);
    img = imgfx.despeckle(img);
    img = imgfx.despeckle(img);
    img = imgfx.sharpen(img);
    return img;
}

if ( application.args.length == 0 ) {
    throw 'Usage:\n\timageviewer imgfile ...';
}
else {
    var loc = application.args[0];
    var lbl = new QLabel();

    var img = new Image();
    img.load( loc );
    if ( !img.isOk() ) {
        throw 'Failed to load image ' + loc;
    }

    println(img.isOk());
    img = apply_watercolor( img );

    lbl.pixmap = img.pixmap();
    lbl.resize(img.width(), img.height());
    lbl.show();
    application.exec();
}

/*
int watercolor(imgdes *srcimg, imgdes *resimg)
{
   imgdes tmpsrc;
   int cols, rows, rcode;
   double gamma = 0.7;

   cols = CALC_WIDTH(srcimg);
   rows = CALC_HEIGHT(srcimg);

   allocimage(&tmpsrc, cols, rows, srcimg->bmh->biBitCount);
   copyimage(srcimg, &tmpsrc);

   gammabrighten(gamma, &tmpsrc, &tmpsrc);
   removenoise(&tmpsrc, &tmpsrc);
   removenoise(&tmpsrc, &tmpsrc);
   removenoise(&tmpsrc, &tmpsrc);
   sharpen(&tmpsrc, &tmpsrc);

   rcode = copyimage(&tmpsrc, resimg);

   freeimage(&tmpsrc);


*/