Package com.alibaba.simpleimage.codec.convertor

Examples of com.alibaba.simpleimage.codec.convertor.NullColorConvertor


    protected void determinColorspace() {
        switch (frameHeader.getNf()) {
            case 1:
                rawImage.setRawColorspace(JPEGColorSpace.Gray);
                rawImage.setColorspace(JPEGColorSpace.Gray);
                colorConvertor = new NullColorConvertor();
                break;

            case 3:
                if (extendImageHeader.isSawJFIFMarker()) {
                    /* JFIF implies YCbCr */
                    rawImage.setRawColorspace(JPEGColorSpace.YCbCr);
                    colorConvertor = new YCbCr2RGBColorConvertor();
                } else if (extendImageHeader.isSawAdobeMarker()) {
                    switch (extendImageHeader.getAdobeTransform()) {
                        case 0:
                            rawImage.setRawColorspace(JPEGColorSpace.RGB);
                            colorConvertor = new NullColorConvertor();
                            break;
                        case 1:
                            rawImage.setRawColorspace(JPEGColorSpace.YCbCr);
                            colorConvertor = new YCbCr2RGBColorConvertor();
                            break;
                        default:
                            /* assume it's YCbCr */
                            rawImage.setRawColorspace(JPEGColorSpace.YCbCr);
                            colorConvertor = new YCbCr2RGBColorConvertor();
                            break;
                    }
                } else {
                    /*
                     * Saw no special markers, try to guess from the component IDs
                     */
                    int cid0 = frameHeader.getComponents()[0].getC();
                    int cid1 = frameHeader.getComponents()[1].getC();
                    int cid2 = frameHeader.getComponents()[2].getC();

                    if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
                        /* assume JFIF w/out marker */
                        rawImage.setRawColorspace(JPEGColorSpace.YCbCr);
                        colorConvertor = new YCbCr2RGBColorConvertor();
                    } else if (cid0 == 82 && cid1 == 71 && cid2 == 66) {
                        /* ASCII 'R', 'G', 'B' */
                        rawImage.setRawColorspace(JPEGColorSpace.RGB);
                        colorConvertor = new NullColorConvertor();
                    } else {
                        /* assume it's YCbCr */
                        rawImage.setRawColorspace(JPEGColorSpace.YCbCr);
                        colorConvertor = new YCbCr2RGBColorConvertor();
                    }
                }

                /* Always guess RGB is proper output colorspace. */
                rawImage.setColorspace(JPEGColorSpace.RGB);
                break;

            case 4:
                if (extendImageHeader.isSawAdobeMarker()) {
                    switch (extendImageHeader.getAdobeTransform()) {
                        case 0:
                            rawImage.setRawColorspace(JPEGColorSpace.CMYK);
                            colorConvertor = new InverseColorConvertor();
                            break;
                        case 2:
                            rawImage.setRawColorspace(JPEGColorSpace.YCCK);
                            colorConvertor = new YCCK2CMYKColorConvertor();
                            break;
                        default:
                            /* assume it's YCCK */
                            rawImage.setRawColorspace(JPEGColorSpace.YCCK);
                            colorConvertor = new YCCK2CMYKColorConvertor();
                            break;
                    }
                } else {
                    /* No special markers, assume straight CMYK. */
                    rawImage.setRawColorspace(JPEGColorSpace.CMYK);
                    colorConvertor = new InverseColorConvertor();
                }
                rawImage.setColorspace(JPEGColorSpace.CMYK);
                break;

            default:
                rawImage.setRawColorspace(JPEGColorSpace.UNKNOWN);
                rawImage.setColorspace(JPEGColorSpace.UNKNOWN);
                colorConvertor = new NullColorConvertor();
                break;
        }
    }
View Full Code Here

TOP

Related Classes of com.alibaba.simpleimage.codec.convertor.NullColorConvertor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.