picasso-transformations icon indicating copy to clipboard operation
picasso-transformations copied to clipboard

TritoneTransformation

Open ghost opened this issue 11 years ago • 2 comments

There is an issue with the TritoneTransformation. The member lut is never initialised and is called on the filterRGB(int x, int y, int rgb) method, throwing a NullPointerException.

ghost avatar Nov 11 '14 18:11 ghost

Hello dwbrito,

Please remove the filter method and put the below method in TritoneTransformation.java . now it will work fine.

 @Override
public Bitmap transform(Bitmap src) {
    lut = new int[256];
    for (int i = 0; i < 128; i++) {
        float t = i / 127.0f;
        lut[i] = ImageMath.mixColors(t, shadowColor, midColor);
    }
    for (int i = 128; i < 256; i++) {
        float t = (i - 127) / 128.0f;
        lut[i] = ImageMath.mixColors(t, midColor, highColor);
    }
    src = super.transform(src);
    lut = null;
    return src;
}

TheSikh avatar Dec 10 '14 08:12 TheSikh

@dwbrito If you would you care to create a pull request for this, I will merge it in. Thanks!

TannerPerrien avatar Dec 13 '14 06:12 TannerPerrien