Transpiled version (5714L) is out of date.
!7 import android.app.Activity; import android.widget.*; import android.graphics.*; import android.hardware.Camera; import android.view.*; p { print("Listing cameras..."); runOnUiThread(r { int n = Camera.getNumberOfCameras(); System.out.println("Cameras: " + n); final Camera cam = Camera.open(0/*n-1*/); Camera.Parameters p = cam.getParameters(); p.setPreviewSize(100, 100); cam.setParameters(p); SurfaceView surfaceView = new SurfaceView(androidContext()); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(new CamCallback()); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); androidShow(surfaceView); cam.setPreviewDisplay(surfaceHolder); cam.startPreview(); print("Preview started."); surfaceView.post(r { cam.takePicture(null, null, null, new JpegCallback()); }); print("Waiting for callback"); }); } static class CamCallback implements SurfaceHolder.Callback { public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) { print("surfaceChanged"); } public void surfaceCreated (SurfaceHolder holder) { print("surfaceCreated"); } public void surfaceDestroyed (SurfaceHolder holder) { print("surfaceDestroyed"); } } static class ShutterCallback implements Camera.ShutterCallback { public void onShutter() { print("Shutter!"); } } static class JpegCallback implements Camera.PictureCallback { public void onPictureTaken (final byte[] data, final Camera cam) { cam.release(); androidShowPrintLog(); thread { print("Camera released."); print("Picture data: " + data.length); print("Uploading..."); print(uploadToImageServer_rawBytes(data, "Phone image")); } } }
Began life as a copy of #1000429
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, exkalrxbqyxc, gwrvuhgaqvyk, hxnwyiuffukg, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, mrjhfnjfopze, nbgitpuheiab, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000431 |
Snippet name: | Android: Take picture & upload (dev.) |
Eternal ID of this version: | #1000431/11 |
Text MD5: | ffb65327b3b9e8be023e862da939fe08 |
Author: | stefan |
Category: | javax android |
Type: | JavaX source code (Android) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-07 18:11:23 |
Source code size: | 1900 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 759 / 761 |
Version history: | 10 change(s) |
Referenced in: | #1000447 - Android: Open camera v2 (developing) #1015068 - Android: Take picture (seems to work!) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |