Search code examples
androiddrawbitmap

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 which 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.


Solution

    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).