我有坐标,我想在jpg图像上绘制一条线或矩形,保存在我的Android设备中,然后保存新文件。
可能吗?我正在向我们ImageIO
试图,但它在Android中无法使用或出现问题并且它不可接受?
任何想法或代码?
答案 0 :(得分:0)
这就是我能够在现有JPEG上绘制绿框的方式。
Bitmap workingBitmap = BitmapFactory.decodeFile( mFullFilePath );
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
// bitmap needs to be mutable
Canvas tmpCanvas = new Canvas(mutableBitmap);
// setup paint parameters
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth( 5 );
paint.setColor(Color.GREEN);
// Rect object was passed; use below to test
// Rect rect = new Rect( 0, 0, 10, 10 );
tmpCanvas.drawRect(rect, paint);
// write the updated file out as a JPG
writeExternalToCache( mutableBitmap, mFullFilePath );
另见: