我正在使用Image
转换在另一张图片上添加Text
和Bitmap
。根据我的代码,我的图像非常模糊:
我期待的是:
我的 Bitmap resultBitmap = bitmap.copy(bitmap.getConfig(), true);
Bitmap bitmapImage =
BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_heart);
bitmapImage = Bitmap.createScaledBitmap(bitmapImage, 90, 90, true);
Canvas canvas = new Canvas(resultBitmap);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
Paint rectPaint = new Paint();
rectPaint.setAntiAlias(true);
rectPaint.setColor(Color.WHITE);
rectPaint.setStyle(Paint.Style.FILL);
rectPaint.setTextSize(40);
rectPaint.setAlpha(400);
paint.setAlpha(150);
canvas.drawText("$250", 20, 400, rectPaint);
canvas.drawBitmap(bitmapImage, 550, 55, null);
canvas.drawRect(0, 350, 140, 420, paint);
bitmap.recycle();
return resultBitmap;
转换代码如下:
Bitmap
我在这里做错了什么?我尝试了所有可能但它总是褪色:(我可以通过在背景中放置黑色透明图像然后在其上添加文本或我也可以通过 private class NetworkTask extends AsyncTask<String, Void, Void> {
protected void doInBackground(String... urls) {
try {
<!--Your network stuff goes here -->
} catch (Exception e) {
}
}
protected void onPostExecute(Void resut) {
// TODO: do something with the feed
}
}
实现它来实现它吗?