简体   繁体   中英

Is it possible to pixelate an image in appcelerator Titanium?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM