0
有人告訴我如何使用java代碼爲iOS創建鈦移動模塊? https://github.com/cashlo/JPEG-compression-for-titaninum-如何使用java代碼爲iOS創建鈦移動模塊?
或
如何編譯爲iOS移動應用下面的代碼(鈦)??
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;
}
}
你能請張貼相關,而不僅僅是鏈接到github上,也部分代碼 - 接受大家的一些問題,如果你想有一個更好的反應。 – david99world
本機iOS模塊是用Obj-C而不是Java編寫的。你的意思是將這個Java代碼移植到Obj-C? –