谁能告诉我如何使用 java 代码为 iOS 创建 titanium 移动模块? https://github.com/cashlo/JPEG-compression-for-titaninum-
或
如何为 iOS 移动应用程序(Titanium)编译以下代码??
package com.cashlo.jpglib;
import java.io.ByteArrayOutputStream;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiConfig;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
@Kroll.module(name = "Jpglib", id = "com.cashlo.jpglib")
public class JpglibModule extends KrollModule {
// Standard Debugging variables
private static final String LCAT = "JpglibModule";
private static final boolean DBG = TiConfig.LOGD;
// You can define constants with @Kroll.constant, for example:
// @Kroll.constant public static final String EXTERNAL_NAME = value;
public JpglibModule(TiContext tiContext) {
super(tiContext);
}
@Kroll.method
public TiBlob compress(TiBlob image) {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
byte[] imageBytes = image.getBytes();
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length, opts);
Integer imageSize = Math.max(opts.outWidth, opts.outHeight);
if (imageSize > 600)
opts.inSampleSize = imageSize/600;
opts.inJustDecodeBounds = false;
Bitmap resized = BitmapFactory.decodeByteArray(image.getBytes(), 0,
imageBytes.length, opts);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
resized.compress(CompressFormat.JPEG, 70, stream);
TiBlob blob = TiBlob.blobFromData(getTiContext(), stream.toByteArray(),
"image/jpeg");
return blob;
}
}
最佳答案
这个模块已经存在?您是否正在尝试完成一些不同的事情
关于java - 如何使用 Java 代码为 iOS 创建钛移动模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13141147/