[英]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. 我正在使用Appcelerator Titanium编写Android和IOS应用程序,但找不到像素化图像的方法。 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.
我已经找到了一种使用Xcode的IOS和Android的Android SDK的方法,但是,如果可能的话,我想在Titanium中这样做以避免将整个应用程序编写两次,一个写给Android,另一个写给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. 如果您在iOS和Android上都有本机方式,则应将它们包装为本机模块,然后将其包含在项目中。
Follow this guide here on the Community wiki -> https://wiki.appcelerator.org/display/guides2/Creating+a+New+Titanium+Module 在社区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. 无需编写和维护两个模块,您可以使用webView并使用JS库或canvas对象对图像进行像素化。
A JS canvas solution to this can be found here: 可以在这里找到JS canvas解决方案:
https://stackoverflow.com/a/19129822/2132015 https://stackoverflow.com/a/19129822/2132015
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.