如何通过Android位图实现预期输出?

时间:2015-09-30 08:12:15

标签: android android-layout android-intent bitmap

我正在使用Image转换在另一张图片上添加TextBitmap。根据我的代码,我的图像非常模糊:

enter image description here

我期待的是:

enter image description here

我的 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 } } 实现它来实现它吗?

0 个答案:

没有答案