[英]how to create titanium mobile module for iOS using java Code?
有誰告訴我如何使用java Code為iOS創建鈦移動模塊? 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;
}
}
這個模塊已經存在? 你有什么不同的東西想要完成
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.