Banding in saved image from Camera on Android
So I've implemented my own version of a camera app on Android. Everything seems to work well except I have a user with a MyTouch 4G and his images are turning out striped and messed up:
Any ideas on what could be causing this? Has anyone seen this before?
Also: Users with other devices are having their pictures come out just fine.
Edit: I've now been able to see this happen on the device. When taking the picture about half the screen flashes green. Then the picture comes out as see开发者_如何学JAVAn above. I've tried saving the byte[] many different ways. It seems the data I'm getting really is corrupt. I'm using the jpeg onPictureTaken callback and just saving off that byte[]. And again. I've ONLY been able to see this on a few MyTouch 4G devices. I really am at a loss here. Any help?
i say you are copying data and you might be missing some pixels on the end of each row. maybe you have the width wrong in your calcs?
I was seeing a very similar issue using the HTC Thunderbolt. I saved the image data byte[] from PictureCallback.onPictureTaken() directly to the SD card. When I viewed the image on the SD card, it showed the same banding effect.
I then realized I was setting the previewSize in the camera parameters. I was using this code:
// Ensure that the camera resolution is a multiple of 8, as the screen may not be.
// TODO: A better solution would be to request the supported preview resolutions
// and pick the best match, but this parameter is not standardized in Cupcake.
Point cameraResolution = new Point();
cameraResolution.x = ( screenResolution.x >> 3 ) << 3;
cameraResolution.y = ( screenResolution.y >> 3 ) << 3;
parameters.setPreviewSize( cameraResolution.x, cameraResolution.y );
When I removed this code and did not set the preview size at all, my images were no longer banded.
精彩评论