Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to create titanium mobile module for iOS using java Code?
    text
    copied!<p>Anyone tell me how to create titanium mobile module for iOS using java Code? <a href="https://github.com/cashlo/JPEG-compression-for-titaninum-" rel="nofollow">https://github.com/cashlo/JPEG-compression-for-titaninum-</a></p> <p>or</p> <p>how to compile the below code for iOS mobile applications(Titanium)??</p> <pre><code>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 &gt; 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; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload