我正在尝试缩小位图,但边缘不像原始图像那样清晰,它有点模糊
我已经检查了下面的链接
请帮忙
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
Matrix m=new Matrix();
m.postRotate(90);
//m.postScale((float)0.5,(float) 0.5);
//Added for merging
//Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Bitmap mutableBitmap = Bitmap.createBitmap(bitmap,0,0,600,400,m,false);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
Canvas canvas = new Canvas(mutableBitmap);
View v=(View)relLay.getParent();
v.setDrawingCacheEnabled(true);
v.buildDrawingCache();
Options options = new BitmapFactory.Options();
options.inScaled = false;
//options.inJustDecodeBounds=true;
options.inSampleSize=2;
//Bitmap viewCapture = v.getDrawingCache().copy(Bitmap.Config.ARGB_8888, true);
// Bitmap newImage = Bitmap.createScaledBitmap(viewCapture, viewCapture.getWidth()/2, viewCapture.getHeight()/2, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
(v.getDrawingCache().copy(Bitmap.Config.ARGB_8888, true)).compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bitmap viewCapture= BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length, options);
v.setDrawingCacheEnabled(false);
Rect src = new Rect(0, 0, viewCapture.getWidth(), viewCapture.getHeight());
Log.d("TEST",""+viewCapture.getWidth()+" "+viewCapture.getHeight());
//Destination RectF sized to the camera picture
Rect dst = new Rect(0, 0, mutableBitmap.getWidth(), mutableBitmap.getHeight());
Log.d("Test",""+mutableBitmap.getWidth()+" "+mutableBitmap.getHeight());
canvas.drawBitmap(viewCapture, src, dst, paint);
// Bitmap newImage = Bitmap.createScaledBitmap(viewCapture, 400,600, true);
mutableBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
如果我尝试缩放 viewCapture 元素会变得模糊