0

I only searched for infos in this community and first time to actually ask something. Please know that I'm new to android programming and also am not good at English.


I'm using canvas to draw a bitmap. I first select color and shape type with dialog. As I touch the screen, the bitmap gets drawn by the color I selected and shape (actually bitmap). The problem happens when I change the color or brush. After changing, when I draw, all the previously drawn bitmap's color and shape changes to new settings.

This is the code and an example image (since my bad english might confused you what I'm talking about). Obviously, it runs by invalidate().

protected void onDraw(Canvas canvas) {
    for (int i = 0; i < mPoints.size(); i += 2) {
        mPaint = new Paint();
        MyPointWColor myP = mPoints.get(i);
        mPaint.setColor(myP.color);
        Bitmap resized = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), brush[brushNum]), 100, 100, true);
        replaceColor_self(resized, mCurColor);
        canvas.drawBitmap(resized,myP.x,myP.y,mPaint);
    }
}

I really had hard time getting all this way. This last part will end this nightmare.

Please, save me!

Benjamin
  • 1,143
  • 1
  • 14
  • 29
KSS
  • 9
  • 1
  • Hello and welcome. You really don't need to excuse multiple times. Everyone started the same way and will be pleased to help you out. – Benjamin May 12 '20 at 16:36
  • I'm not sure what your `replaceColor_self()` method does, exactly, but you never update `mCurColor` before calling it. I would assume that it should be set to the current `MyPointWColor` color value. – Mike M. May 13 '20 at 02:46

0 Answers0