Custom Android Brush Template / Image

I have an 8x8 image. (bitmap - can be changed)

What I want to do is the ability to draw a shape using the Path and Paint object on my SurfaceView .

At the moment, all I can do is fill the form with solid color. How to draw it using a template.

Example

In the image you can see the brush drawing (Cross). It can be anything: from the cross to the donut or elf.

How would I draw this background pattern.

I also ultimately want to apply colors to it.

So far, my theory has been to create a region of the clip of a figure and draw bitmap images until the region is covered, but this is an extreme overflow in processing. The sound is not perfect.

In terms of coloring, I can edit the brushes to be alpha, fill them with the background color, and then draw the images on top. The real problem is the alternation of such patterns.

I found several questions of a similar nature, all unanswered and / or not applicable to my situation. (using xmls on views, etc.)

+6
source share
1 answer

You have checked this blog . Its use of BitmapShader

Example:

  //Initialize the bitmap object by loading an image from the resources folder fillBMP = BitmapFactory.decodeResource(m_context.getResources(), R.drawable.cross); //Initialize the BitmapShader with the Bitmap object and set the texture tile mode fillBMPshader = new BitmapShader(fillBMP, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); fillPaint.setStyle(Paint.Style.FILL); //Assign the 'fillBMPshader' to this paint fillPaint.setShader(fillBMPshader); //Draw the fill of any shape you want, using the paint object. canvas.drawCircle(posX, posY, 100, fillPaint); 
+18
source

All Articles