FileDocCategorySizeDatePackage
RggbChannelVector.javaAPI DocAndroid 5.1 API7426Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.params

RggbChannelVector

public final class RggbChannelVector extends Object
Immutable class to store a 4-element vector of floats indexable by a bayer RAW 2x2 pixel block.

Fields Summary
public static final int
COUNT
The number of color channels in this vector.
public static final int
RED
Red color channel in a bayer Raw pattern.
public static final int
GREEN_EVEN
Green color channel in a bayer Raw pattern used by the even rows.
public static final int
GREEN_ODD
Green color channel in a bayer Raw pattern used by the odd rows.
public static final int
BLUE
Blue color channel in a bayer Raw pattern.
private final float
mRed
private final float
mGreenEven
private final float
mGreenOdd
private final float
mBlue
Constructors Summary
public RggbChannelVector(float red, float greenEven, float greenOdd, float blue)
Create a new {@link RggbChannelVector} from an RGGB 2x2 pixel.

All pixel values are considered normalized within {@code [0.0f, 1.0f]} (i.e. {@code 1.0f} could be linearized to {@code 255} if converting to a non-floating point pixel representation).

All arguments must be finite; NaN and infinity is not allowed.

param
red red pixel
param
greenEven green pixel (even row)
param
greenOdd green pixel (odd row)
param
blue blue pixel
throws
IllegalArgumentException if any of the arguments were not finite


                                                                                       
             
               
        mRed = checkArgumentFinite(red, "red");
        mGreenEven = checkArgumentFinite(greenEven, "greenEven");
        mGreenOdd = checkArgumentFinite(greenOdd, "greenOdd");
        mBlue = checkArgumentFinite(blue, "blue");
    
Methods Summary
public voidcopyTo(float[] destination, int offset)
Copy the vector into the destination in the order {@code [R, Geven, Godd, B]}.

param
destination an array big enough to hold at least {@value #COUNT} elements after the {@code offset}
param
offset a non-negative offset into the array
throws
NullPointerException If {@code destination} was {@code null}
throws
ArrayIndexOutOfBoundsException If there's not enough room to write the elements at the specified destination and offset.

        checkNotNull(destination, "destination must not be null");
        if (destination.length - offset < COUNT) {
            throw new ArrayIndexOutOfBoundsException("destination too small to fit elements");
        }

        destination[offset + RED] = mRed;
        destination[offset + GREEN_EVEN] = mGreenEven;
        destination[offset + GREEN_ODD] = mGreenOdd;
        destination[offset + BLUE] = mBlue;
    
public booleanequals(java.lang.Object obj)
Check if this {@link RggbChannelVector} is equal to another {@link RggbChannelVector}.

Two vectors are only equal if and only if each of the respective elements is equal.

return
{@code true} if the objects were equal, {@code false} otherwise

        if (obj == null) {
            return false;
        } else if (this == obj) {
            return true;
        } else if (obj instanceof RggbChannelVector) {
            final RggbChannelVector other = (RggbChannelVector) obj;
            return mRed == other.mRed &&
                    mGreenEven == other.mGreenEven &&
                    mGreenOdd == other.mGreenOdd &&
                    mBlue == other.mBlue;
        }
        return false;
    
public floatgetBlue()
Get the blue component.

return
a floating point value (guaranteed to be finite)

        return mBlue;
    
public floatgetComponent(int colorChannel)
Get the component by the color channel index.

{@code colorChannel} must be one of {@link #RED}, {@link #GREEN_EVEN}, {@link #GREEN_ODD}, {@link #BLUE}.

param
colorChannel greater or equal to {@code 0} and less than {@link #COUNT}
return
a floating point value (guaranteed to be finite)
throws
IllegalArgumentException if {@code colorChannel} was out of range

        if (colorChannel < 0 || colorChannel >= COUNT) {
            throw new IllegalArgumentException("Color channel out of range");
        }

        switch (colorChannel) {
            case RED:
                return mRed;
            case GREEN_EVEN:
                return mGreenEven;
            case GREEN_ODD:
                return mGreenOdd;
            case BLUE:
                return mBlue;
            default:
                throw new AssertionError("Unhandled case " + colorChannel);
        }
    
public floatgetGreenEven()
Get the green (even rows) component.

return
a floating point value (guaranteed to be finite)

        return mGreenEven;
    
public floatgetGreenOdd()
Get the green (odd rows) component.

return
a floating point value (guaranteed to be finite)

        return mGreenOdd;
    
public final floatgetRed()
Get the red component.

return
a floating point value (guaranteed to be finite)

        return mRed;
    
public inthashCode()
{@inheritDoc}

        return Float.floatToIntBits(mRed) ^
                Float.floatToIntBits(mGreenEven) ^
                Float.floatToIntBits(mGreenOdd) ^
                Float.floatToIntBits(mBlue);
    
private java.lang.StringtoShortString()
Return the RggbChannelVector as a string in compact form.

{@code "{R:%f, G_even:%f, G_odd:%f, B:%f}"}, where each {@code %f} respectively represents one of the the four color channels.

return
compact string representation of {@link RggbChannelVector}

        return String.format("{R:%f, G_even:%f, G_odd:%f, B:%f}",
                mRed, mGreenEven, mGreenOdd, mBlue);
    
public java.lang.StringtoString()
Return the RggbChannelVector as a string representation.

{@code "RggbChannelVector{R:%f, G_even:%f, G_odd:%f, B:%f}"}, where each {@code %f} respectively represents one of the the four color channels.

return
string representation of {@link RggbChannelVector}

        return String.format("RggbChannelVector%s", toShortString());