@Events(values = { "Ready (Success As Boolean)","PictureTaken (Data() As Byte)","PreviewTaken (Data() As Byte)" })
public void getPicture(int Width, int Height){
FrameWidth = Width;
FrameHeight = Height;
try {
Log.i("B4A", "Try Mode.");
Log.i("B4A", "IsPreviewOn is True");
isDecoding = true;
Log.i("B4A", "Decoding is true.");
c.setOneShotPreviewCallback(this);
Log.i("B4A", "Callback Done.");
Log.i("B4A", "Outside isDecoding.");
} catch (Exception e) {
Log.i("B4A", "An error occured.");
return;
}
return;
}
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Log.i("B4A", "In onPreviewFrame");
int width = FrameWidth;
int height = FrameHeight;
int[] temp = new int[width * height];
OutputStream out = new ByteArrayOutputStream();
Bitmap bm = null;
Log.i("B4A", "Initialize raw2jpg");
raw2jpg(temp, data, width, height);
bm = Bitmap.createBitmap(temp, width, height, Bitmap.Config.RGB_565);
bm.compress(CompressFormat.JPEG, 100, out);
mCurrentFrame = ((ByteArrayOutputStream) out).toByteArray();
isDecoding = false;
Log.i("B4A", "isDecoding false");
ba.raiseEvent(null, eventName + "_previewtaken", data);
}