我陷入了一個奇怪的問題。 在我的應用程序中,用戶可以更改他/她的個人資料圖片。並且該圖像在一輪中顯示。 我正在從攝像頭/文件(庫)&圖像轉換圓角位圖我使用下面的代碼。獲取錯誤致命信號11(SIGSEGV)在0x09050941(代碼= 1)在使用畫布進行圓形圖像
public static Bitmap getRoundedShape(Context context, Bitmap scaleBitmapImage, int imageWidth, int imageHeight) {
int targetWidth = getDPEquivalentPixels(context, imageWidth);
int targetHeight = getDPEquivalentPixels(context, imageHeight);
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(((float) targetWidth - 1)/2, ((float) targetHeight - 1)/2, (Math.min(((float) targetWidth), ((float) targetHeight))/2), Path.Direction.CW);
Paint paint = new Paint();
paint.setColor(Color.GRAY);
// paint.setStyle(Paint.Style.STROKE);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);
canvas.drawOval(new RectF(0, 0, targetWidth, targetHeight), paint);
canvas.clipPath(path);
Bitmap sourceBitmap = scaleBitmapImage;
canvas.drawBitmap(sourceBitmap, new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()), new Rect(0, 0, targetWidth, targetHeight), null);
return targetBitmap;
}
首先我將圖像上傳到服務器進行壓縮。然後我將它保存在本地SQLite中,作爲字節數組&使用上述方法將其轉換爲圓形位圖以顯示在ImageView
上。
現在從現在開始,我將參考SQLite
獲取配置文件映像。我的問題是第一次圓角代碼工作正常,但後來當我使用SQLIte圖像&嘗試將其轉換爲圓形我收到以下錯誤。
A/libc(14809): Fatal signal 11 (SIGSEGV) at 0x5f763ee0 (code=1), thread 14809
編輯::
我有用戶POJO從而節省從SQLite的retrived用戶對象。我將這個Pojo轉換成存儲在SharedPreferance中的json &,直到用戶會話處於激活狀態。
public class User {
private int uid;
private String userName;
private String firstName;
private String lastName;
private String email;
private Date dob;
private String gender;
private int delFlag;
private int pin;
private Bitmap imageData;
}
我使用GSON的JSON到POJO &副詩句解析。但我不知道Gson庫是否會正確解析我的imageData
(數據類型位圖)。這可能會造成問題。
我可以看到它是在libc中,但通常如果你看到LogCat中的整個轉儲,你可以告訴c代碼和它在崩潰之前是什麼java? – 2013-03-11 10:28:14
您可能會在本機代碼中取消引用空指針。如果您沒有將任何空引用傳遞迴位圖轉換器,我會仔細檢查。只需逐行調試即可。 – 2013-03-11 10:33:41
@hack_on - 在LogCat中,我只看到這一行。其他日誌通常只是我在正常執行中獲得的。 – hemu 2013-03-11 10:41:25