Search code examples
imageimage-processingcolorsdartpixel

Get color of Pixel from an image


I try to get the color of an Pixel in an Image .

Via the Image class of the package:image/image.dart package, i can access the pixel at a given coordinate x and y.

This gives me a integer.

How can i get the color from this?


Solution

  • You can split the integer into its color parts using

        int c1 = image.getPixel(x, y);
        int r1 = getRed(c1);
        int g1 = getGreen(c1);
        int b1 = getBlue(c1);
        int a1 = getAlpha(c1);
    

    See also https://github.com/brendan-duncan/image/blob/master/test/color_test.dart for an example