Phreak87 / LeptonicaSharp

Full featured wrapper for leptonica 1.77.0
Other
8 stars 5 forks source link

PixColormap Arrays are not correct #57

Closed fdncred closed 5 years ago

fdncred commented 5 years ago

There is some problem with how the color arrays for a PixColormap are created. It looks like they're out of order to me in the Array_Color .

pix.colormap.Array_Color[1]
"{Name=ced3d4ff, ARGB=(206, 211, 212, 255)}"
    A: 206
    B: 255
    G: 212
    R: 211
pix.colormap.Array_RGBAQ[1]
{R:212 G:211 B:206 A:255}
    AsSystemColor: "{Name=ffd4d3ce, ARGB=(255, 212, 211, 206)}"
    alpha: 255
    blue: 206
    green: 211
    red: 212
fdncred commented 5 years ago

I think it should be this since bytes are in BGRA order.

public Color[] Array_Color
{
    get {
        if ((Values == null))
        { return null; }

        List<Color> QList = new List<Color>();

        for (int i = 0; i <= Array_Bytes.Count() - 1; i += 4) {
            byte[] B = new byte[4];
            System.Array.Copy(Array_Bytes, i, B, 0, B.Length);
            QList.Add(Color.FromArgb(B[3], B[2], B[1], B[0])); // B G R A
        }

        return QList.ToArray();
    }
}
Phreak87 commented 5 years ago

thats right. i will fix it