哦,我的第一个问题〜
这里是我的problem.I'm提出申请拍照和水印添加到它。
第一步,作为应用程序启动,我采取了一枪(使用最大分辨率,like2592 * 1952年(500万))。拍摄完成后,我按OK返回到我的应用程序的视图,应用程序崩溃。但是,如果我应用程序启动的分辨率不是那么大(比如3M,2M,1M),那么它可以正常工作。然后,第二个镜头的分辨率为5M,它可能很有趣办法。 我很困惑,任何人都可以帮助我吗? 下面是关于解码图像文件的一些代码。为照片添加水印
public void onClick(View v){
Bitmap bitmap1 =mcreateBitmap(bitmaptmp, "watermark");
// bitmaptmp=null;
/* Associate the Bitmap to the ImageView */
if (bitmap1 != null) {
mImageView.setImageBitmap(bitmap1);
}
mImageView.setVisibility(View.VISIBLE);
// try {
// String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
// String imageFileName = JPEG_FILE_PREFIX + timeStamp;
// saveMyBitmap(imageFileName,bitmap1);
// bitmap1=null;
// } catch (IOException e) {
// e.printStackTrace();
// }
}
公共位图mcreateBitmap(位图的src,字符串str){
Time t = new Time();
t.setToNow();
int w = src.getWidth();
int h = src.getHeight();
String mstrTitle = "11:"+t.hour + ":" + t.minute + ":" + t.second;
String xx="34:"+x;
String yy="44:"+y;
Bitmap bmpTemp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas canvas = new Canvas(bmpTemp);
Paint photoPaint = new Paint();
photoPaint.setDither(true);
photoPaint.setFilterBitmap(true);
Rect s = new Rect(0, 0, src.getWidth(), src.getHeight());
Rect d = new Rect(0, 0, w, h);
canvas.drawBitmap(src, s, d, photoPaint);
String familyName = "new";
Typeface font = Typeface.create(familyName, Typeface.BOLD);
photoPaint.setColor(Color.BLUE);
photoPaint.setTypeface(font);
photoPaint.setTextSize(18);
canvas.drawText(mstrTitle,40, 20, photoPaint);
canvas.drawText(xx,40, 40, photoPaint);
canvas.drawText(yy,40, 60, photoPaint);
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
return bmpTemp;
}
这里是logcat的:
十一月1日至5日:25:25.791:E/dalvikvm堆(11147):20238336对于此过程,字节外部分配太大。 11月1日至5日:25:25.791:E/dalvikvm(11147):内存:堆大小= 2923KB,分配= 2460KB,位图大小= 1235KB,极限= 13756KB 11月1日至5日:25:25.791:E/dalvikvm(11147):修剪信息:足迹= 2883KB,允许的足迹= 3267KB,修剪= 344KB 01-05 11:25:25.791:E/GraphicsJNI(11147):VM不会让我们分配20238336字节 01-05 11:25:25.801:d/AndroidRuntime(11147):关闭VM 11月1日至五日:25:25.801:W/dalvikvm(11147):线程ID = 1:螺纹与未捕获的异常退出(组= 0x40028a00) 01- 05 11:25:25.801:E/AndroidRuntime(11147):致命异常:主 01-05 11:25:25.801:E/AndroidRuntime(11147):java.lang.OutOfMemoryError:位图大小超过VM预算 01-05 11:25:25.801:E/AndroidRuntime(11147):在android.graphics.Bitmap.nativeCreate(Nati已经方法) 11月1日至五日:25:25.801:E/AndroidRuntime(11147):在android.graphics.Bitmap.createBitmap(Bitmap.java:574) 11月1日至五日:25:25.801:E/AndroidRuntime(11147 ):at com.kevin.photowatermark.PhotowatermarkActivity.mcreateBitmap(PhotowatermarkActivity.java:403)
欢迎来到StackOverlow!你能提供关于崩溃的更多信息吗?就像logcat堆栈跟踪一样。 – Veger
我希望如此。但正如你所知,在模拟器中,你不能使用相机。所以,我使用的唯一方法是将应用程序安装在真实的设备上。 – kevin320
使用Eclipse调试器和USB电缆运行应用程序,并且您还获得了logcat反馈! – Veger