PorterduffXfermode: Clear a section of a bitmap

前端 未结 3 1386
北恋
北恋 2020-12-02 20:36

The goal is to draw a bitmap and over the top of something, and draw shapes that ERASE the underlying area of the bitmap.

I have a proof of concept to try and underst

3条回答
  •  执笔经年
    2020-12-02 21:09

    As Romain Guy points out here: google stuff you need to write on the Bitmap, not the canvas with the circles you are trying to clear, then set it to the main Canvas in your View. So, do something like:

    // Generate bitmap used for background
                bm = BitmapFactory.decodeFile("mnt/sdcard/Pictures/test.jpg");
    
    // Create the paint and set the bitmap
    Canvas temp = new Canvas(bm.getHeight(), bm.getWidth, Config.ARGB_8888);
    
    // in onDraw()
    temp.drawCircle((w / 8) * (ii * 2 + 1), (h / 8) * (i * 2 + 1), w / 8 * 0.8f, pDraw[i*4 + ii]);
    
    // After loop
    canvas.drawBitmap(....);
    

    Hope this helps.

提交回复
热议问题