summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/imageviewer/imageviewer.js
diff options
context:
space:
mode:
Diffstat (limited to 'kjsembed/docs/examples/imageviewer/imageviewer.js')
-rw-r--r--kjsembed/docs/examples/imageviewer/imageviewer.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/imageviewer/imageviewer.js b/kjsembed/docs/examples/imageviewer/imageviewer.js
new file mode 100644
index 00000000..f69d63c3
--- /dev/null
+++ b/kjsembed/docs/examples/imageviewer/imageviewer.js
@@ -0,0 +1,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);
+
+
+*/