How to convert a 24 Bit PNG to 3 Bit PNG using Floyd–Steinberg dithering?

前端 未结 4 1855
予麋鹿
予麋鹿 2020-12-16 18:11

How to convert a 24 Bit PNG to 3 Bit PNG using Floyd–Steinberg dithering? java.awt.image.BufferedImage should be used to get and set RGB values.

On wik

4条回答
  •  长情又很酷
    2020-12-16 18:54

    source code needs the missing method "diff" in the static class C3. otherwise, it doesn't compile or work.

    here's the missing diff method:

    public int diff(C3 o) {
        int Rdiff = o.r - this.r;
        int Gdiff = o.g - this.g;
        int Bdiff = o.b - this.b;
        int distanceSquared = Rdiff*Rdiff + Gdiff*Gdiff + Bdiff*Bdiff;
        return distanceSquared;
    }
    

提交回复
热议问题