Flutter or dart, how to change ui.Image (content) color, not background?

Viewed 35

I have a ui.Image which has already been decoded. It contains only white background and black content, let's a "question" mark there.

I will use Canvas and drawImage to paint the ui.Image after I change color from black to red or another single color.

WDYT?

thank you

1 Answers

Use https://pub.dev/packages/image

        Image image;//decode image from your image
        
        //get Pixel at x,y and check if Color is Black
        image.getPixel(x, y); 
        //setPixelSafe set pixel at x,y to new color
        image.setPixelSafe(x, y, newColor);
        
        //convert Image to ui.Image and Draw it in Canvas
Related