2
我試圖用相機拍照,修改拍攝的圖像,然後在用戶點擊接受後在相機中將修改的圖像顯示給用戶。這裏是我的代碼,上面那裏我做了創建該錯誤代碼更改評論:在Android中使用相機拍攝照片時出現致命的信號11和奇怪的錯誤信息
private class TakePictureThread extends Thread {
private Camera.PictureCallback pPictureCallback;
@Override
public void run() {
pPictureCallback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(0, info);
SurfaceView surfaceView = mCameraCaptureView.getSurfaceView();
// TODO: scale this such that we don't need to scale the cropped image
Bitmap unrotatedRawImage =
ImageUtils.decodeSampledBitmap(data,
surfaceView.getWidth(),
surfaceView.getHeight(), Bitmap.Config.RGB_565);
Bitmap rawImage =
ImageHelper.rotate(unrotatedRawImage, info.orientation);
unrotatedRawImage.recycle();
mCroppedImage = cropRawCapturedImage(rawImage);
rawImage.recycle();
mCroppedImage = Bitmap.createScaledBitmap(
mCroppedImage,
ImageSize.CARD.getPixelWidth(),
ImageSize.CARD.getPixelHeight(),
false);
mImagePreview.setImageBitmap(mCroppedImage);
if (useBlurringAndGradient()) {
//new code
Bitmap blurredBitmap = ImageUtils.blurImage(mCroppedImage);
mImagePreview.setImageBitmap(blurredBitmap);
}
handlePhotoTaken();
}
};
mCameraCaptureView.getCamera().takePicture(null, null, pPictureCallback);
}
}
而且blurImage方法:
/**
* Performs the max blur possible 20 times on the bitmap provided.
*/
static private Bitmap blurCardImage(Bitmap bitmap) {
RenderScript rs = RenderScript.create(MainApp.getInstance());
Bitmap blurredBitmap =
Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
for (int i = 0; i < 20; i++) {
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, blurredBitmap);
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
blurScript.setRadius(25.f);
blurScript.setInput(allIn);
blurScript.forEach(allOut);
allOut.copyTo(blurredBitmap);
bitmap = blurredBitmap;
}
rs.destroy();
return bitmap;
}
這裏是日誌看起來像發生這種情況時:
10-20 10:20:15.588: E/Camera(18230): Unknown message type 62273
10-20 10:20:15.588: E/Camera(18230): Unknown message type 62274
10-20 10:20:21.468: D/ProgressBar(18230): updateDrawableBounds: left = 0
10-20 10:20:21.468: D/ProgressBar(18230): updateDrawableBounds: top = 0
10-20 10:20:21.468: D/ProgressBar(18230): updateDrawableBounds: right = 228
10-20 10:20:21.468: D/ProgressBar(18230): updateDrawableBounds: bottom = 228
10-20 10:20:22.408: D/dalvikvm(18230): GC_FOR_ALLOC freed 11182K, 19% free 55902K/68748K, paused 47ms, total 47ms
10-20 10:20:22.418: V/RenderScript(18230): 0x7b761008 Launching thread(s), CPUs 4
10-20 10:20:22.428: V/RenderScript(18230): User-backed allocation failed stride requirement, falling back to separate allocation
10-20 10:20:22.498: A/libc(18230): Fatal signal 11 (SIGSEGV) at 0x7d9d7000 (code=1), thread 18869 (.myapp)
10-20 10:20:22.498: A/libc(18230): Fatal signal 11 (SIGSEGV) at 0x7d9d7000 (code=1), thread 18867 (.myapp)
10-20 10:20:22.498: A/libc(18230): Fatal signal 11 (SIGSEGV) at 0x7d9d7000 (code=1), thread 18868 (.myapp)
10-20 10:20:22.498: A/libc(18230): Fatal signal 11 (SIGSEGV) at 0x7d9d7000 (code=1), thread 18870 (.myapp)
啓用詳細日誌級別 – ben75 2014-10-17 21:21:07
@ ben75我將日誌更新爲詳細級別。 – mpellegr 2014-10-20 14:22:31
爲什麼這會降低投票率?如有必要,我可以提供更多細節。 – mpellegr 2014-10-23 19:49:34