DrawBitmap not working

Hi

I have this image, 200x200 pixels.

I want to draw part of the image, for example, Part #2 or # 3.
I can only draw part #1.

canvas.DrawBitmap(bitmap, new SKRect(0, 0, 100, 100), new SKRect(0, 0, 100, 100)); // #1

when I try to draw other parts, nothing appears.
How can I do that?
Thank you in advance

Tagged:

Best Answer

  • PaulNTUPaulNTU US ✭✭✭
    edited May 31 Accepted Answer

    You havent provided your code for the problem areas so its difficult to see what's wrong

    the first SKRect is your source rectangle (What part of the image to draw from your source) and the second is your destination (Where to draw onto the new bitmap)

    Try these commands

    // Draw #1 to #2
    canvas.DrawBitmap(bitmap, new SKRect(0, 0, 100, 100), new SKRect(100, 0, 200, 100)); 
    
    // Draw #1 to #3
    canvas.DrawBitmap(bitmap, new SKRect(0, 0, 100, 100), new SKRect(0, 100, 100, 200)); 
    

    HTH
    Paul

Answers

  • PaulNTUPaulNTU USMember ✭✭✭
    edited May 31 Accepted Answer

    You havent provided your code for the problem areas so its difficult to see what's wrong

    the first SKRect is your source rectangle (What part of the image to draw from your source) and the second is your destination (Where to draw onto the new bitmap)

    Try these commands

    // Draw #1 to #2
    canvas.DrawBitmap(bitmap, new SKRect(0, 0, 100, 100), new SKRect(100, 0, 200, 100)); 
    
    // Draw #1 to #3
    canvas.DrawBitmap(bitmap, new SKRect(0, 0, 100, 100), new SKRect(0, 100, 100, 200)); 
    

    HTH
    Paul

Sign In or Register to comment.