开发者

What does 'Paint' parameter do in android.graphics.Canvas.drawBitmap()?

I have a question about drawBitmap.

android.graphics.Canvas.drawBitmap(Bitmap bitmap, float left, float top, Paint paint)

What does that Paint paint? For example I have a picture.jpg and I make

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.picture);
  paint = new Paint(); 
paint.setColor(Color.BLUE);

canvas.drawBitmap(bitmap, 0, 0, paint);

What can I do with that "paint" when I have a real picture not some canvas.drawCircle. Is there any way I can change pictures color or something like that?

Yes and another question. For example I draw circle in mspaint in 80x80 size and my background stays plain white. When I use that drawing in my program it shows circle + that white background. Is there any way that there will be displayed only circle without background. Maybe somebody can suggest some program in which I can make that happen or whic开发者_高级运维h code should I use in my program? (circle is just example, there can be anything)

Yes and excuse to use circle's background same as program's background is not appropriate, because my program's background isn't white or black or any other color, it is picture.


  1. Paint objects can affect the rendering of the Bitmap. For example, they be used to mask the drawing of the Bitmap.

  2. Save your circle as a PNG or GIF, and set the background as transparent (I do not know if MS Paint can do this).


i suggest gimp for image editing with transparency.

start a new image, delete the default layer, add a transparent layer, then paste your image over that. you can use the fuzzy select tool to trim any white space, then save as .png and you have a transparent image!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜