0

I'm writing an Android and IOS app using Appcelerator Titanium, and I can't find a way to pixelate an image. The app that I'm writing, needs to do that: pixelate a given image with a parameter given by user, (the greater the number, the greater the pixels). I have found a way to do it with Xcode for IOS, and in Android SDK for Android, but if possible, I would like to do it in Titanium to avoid writing the whole app twice, one for Android and other for IOS.

Is there a way to do it?

Thank you.

1 Answers1

0

If you have a native way in iOS and both Android you should wrap these as native modules and then include them in the project.

Follow this guide here on the Community wiki -> https://wiki.appcelerator.org/display/guides2/Creating+a+New+Titanium+Module

Then you can write a function that wraps the modules and returned the processed object. eg.

var processImage = function() {
    if (Titanium.Platform.name == 'android') {
        // Android stuff

        var imageProcess = require('ti.imageProcess');

        return imageProcess.doImage('/voo/bar', /*more options */)
    } else {
        // etc
    }
};

Instead of writing and maintaining two modules you could use a webView and use a JS library or the canvas object to pixelate the image.

A JS canvas solution to this can be found here:

https://stackoverflow.com/a/19129822/2132015

Community
  • 1
  • 1
Michael
  • 276
  • 2
  • 7
  • Thank you very much. So, if I understand, I have to develope the code for image processing separately in IOS and Android, and then write a function which calls those module functions, one or other depending of the system, isn't it?. – Paco Gaspar Feb 03 '15 at 10:58
  • Exactly that. You could find a pre existing image processing module for the native versions and then the Titanium module will just wrap these methods, taking an image object for it to be processed. The other option is to use javascript and manipulate the image in a webView, this would also work quite well. – Michael Feb 03 '15 at 13:57