API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.image. JOTAbstractPixel View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

/*
------------------------------------
JavaOnTracks          Thibaut Colar
tcolar-jot AT colar DOT net
Artistic Licence 2.0
http://www.javaontracks.net
------------------------------------
 */

package net.jot.image;

/**
 * Represent the (color) data for a pixel (RGBA)
 * @author thibautc
 */
public class JOTAbstractPixel {
    int red;
    int blue;
    int green;
    int alpha;
    
    public JOTAbstractPixel(int red, int green, int blue, int alpha)
    {
        this.red=red;
        this.blue=blue;
        this.green=green;
        this.alpha=alpha;
    }

    public int getAlpha()
    {
        return alpha;
    }

    public int getBlue()
    {
        return blue;
    }

    public int getGreen()
    {
        return green;
    }

    public int getRed()
    {
        return red;
    }

    public void setAlpha(int alpha)
    {
        this.alpha = alpha;
    }

    public void setBlue(int blue)
    {
        this.blue = blue;
    }

    public void setGreen(int green)
    {
        this.green = green;
    }

    public void setRed(int red)
    {
        this.red = red;
    }

    public int hashCode()
    {
        int hash = 5;
        hash = 41 * hash + this.red;
        hash = 41 * hash + this.blue;
        hash = 41 * hash + this.green;
        hash = 41 * hash + this.alpha;
        return hash;
    }
    
    /**
     * Compares two pixels (macthing color)
     * @param comp
     * @return
     */
    public boolean equals(Object comp)
    {
        if( ! (comp instanceof JOTAbstractPixel))
            return false;
        JOTAbstractPixel compPixel=(JOTAbstractPixel)comp;
        boolean same= compPixel.getRed() == getRed() &&
                compPixel.getBlue() == getBlue() &&
                compPixel.getGreen() == getGreen() &&
                compPixel.getAlpha() == getAlpha();
        return same;
    }

    void asByteArray()
    {
        byte[] b=new byte[16];
        b[0]=(byte)(getRed() & 0xff);
        b[1]=(byte)(getRed() >> 8& 0xff);
        b[2]=(byte)(getRed() >> 16 & 0xff);
        b[3]=(byte)(getRed() >> 24 & 0xff);
        b[4]=(byte)(getGreen() & 0xff);
        b[5]=(byte)(getGreen() >> 8& 0xff);
        b[6]=(byte)(getGreen() >> 16 & 0xff);
        b[7]=(byte)(getGreen() >> 24 & 0xff);
        b[8]=(byte)(getBlue() & 0xff);
        b[9]=(byte)(getBlue() >> 8& 0xff);
        b[10]=(byte)(getBlue() >> 16 & 0xff);
        b[11]=(byte)(getBlue() >> 24 & 0xff);
        b[12]=(byte)(getAlpha() & 0xff);
        b[13]=(byte)(getAlpha() >> 8& 0xff);
        b[14]=(byte)(getAlpha() >> 16 & 0xff);
        b[15]=(byte)(getAlpha() >> 24 & 0xff);
    }
}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar