Hello everyone!
I'm trying to grab a subsection of a bitmap with CreateBitmap(orig,
x,y,width,height) but always getting a width and height of -1 in
Android 2.2. Anyone have any idea? I figured if it failed, I'd get
null back, so I'm a bit confused.
Right now I am doing it on a Motorola Droid while inside of the
preview frame callback, as below.
public void onPreviewFrame(byte[] _data, Camera _camera) {
Log.i(DEBUG_TAG,"Preview Frame Callback");
Camera.Parameters params =
mCamera.getParameters();
Size size = params.getPreviewSize();
int he = size.height;
int wi = size.width;
int[] rgb = new int[he*wi];
YuvImage im = new YuvImage(_data,
ImageFormat.NV21, wi,he,null);
Rect r = new Rect(0,0,wi,he);
ByteArrayOutputStream outStream = new
ByteArrayOutputStream();
im.compressToJpeg(r, 75, outStream);
ByteArrayInputStream is = new
ByteArrayInputStream(outStream.toByteArray());
Bitmap bit = BitmapFactory.decodeStream(is);
Bitmap facePic = Bitmap.createBitmap(bit, 0, 0,
50, 50);
No matter what I do, when I examine facePic immediately after it is
created, it has the correct density, but it's width and height is -1
(examining it in the Eclipse debugger). Anyone have any ideas?
~ Stump
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en