Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
Can I use this code to take a photo and display it?
D Hagy
Greenhorn
Posts: 12
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi!
Sorry for the question, but now I can't try it, so I want to ask you, that If I use this code, I will be able to take a photo and display it in the framelayout?
import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; public class camera_surface extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.camera_surface); Button scan_it = (Button) findViewById(R.id.camera_button); scan_it.setOnClickListener(new View.OnClickListener() { FrameLayout fl = (FrameLayout) findViewById(R.id.preview); @Override public void onClick(View v) { // TODO Auto-generated method stub takePicture(); } private void takePicture() { // TODO Auto-generated method stub Camera camera = Camera.open(); Camera.Parameters parameters = camera.getParameters(); camera.takePicture(null, rawCallback, null); camera.release(); } PictureCallback rawCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { // TODO Do something with the image RAW data. byte[] picture; picture = data; Bitmap pic = BitmapFactory.decodeByteArray(data, 0, data.length); Canvas c = new Canvas(pic); fl.draw(c); } }; }); } }
Thanks
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to create sdcard and mount on the emulator
Is there any problem with this code?
Help to insert/retreive image from database
How to keep the image still after capturing through camera in android
java.lang.Integer error
More...