gpt4 book ai didi

java - 如何使用 Java 代码为 iOS 创建钛移动模块?

转载 作者:行者123 更新时间:2023-11-28 22:46:18 24 4
gpt4 key购买 nike

谁能告诉我如何使用 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;
}

}

最佳答案

这个模块已经存在?您是否正在尝试完成一些不同的事情

https://marketplace.appcelerator.com/apps/1184?1982793044

关于java - 如何使用 Java 代码为 iOS 创建钛移动模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13141147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com