614 * this <code>ColorModel</code>.
615 * If this <code>transferType</code> is not supported, a
616 * <code>UnsupportedOperationException</code> will be
617 * thrown. Since
618 * <code>ColorModel</code> is an abstract class, any instance
619 * must be an instance of a subclass. Subclasses inherit the
620 * implementation of this method and if they don't override it, this
621 * method throws an exception if the subclass uses a
622 * <code>transferType</code> other than
623 * <code>DataBuffer.TYPE_BYTE</code>,
624 * <code>DataBuffer.TYPE_USHORT</code>, or
625 * <code>DataBuffer.TYPE_INT</code>.
626 * @param inData an array of pixel values
627 * @return the value of the red component of the specified pixel.
628 * @throws ClassCastException if <code>inData</code>
629 * is not a primitive array of type <code>transferType</code>
630 * @throws ArrayIndexOutOfBoundsException if
631 * <code>inData</code> is not large enough to hold a pixel value
632 * for this <code>ColorModel</code>
633 * @throws UnsupportedOperationException if this
634 * <code>tranferType</code> is not supported by this
635 * <code>ColorModel</code>
636 */
637 public int getRed(Object inData) {
638 int pixel=0,length=0;
639 switch (transferType) {
640 case DataBuffer.TYPE_BYTE:
641 byte bdata[] = (byte[])inData;
642 pixel = bdata[0] & 0xff;
643 length = bdata.length;
644 break;
645 case DataBuffer.TYPE_USHORT:
646 short sdata[] = (short[])inData;
647 pixel = sdata[0] & 0xffff;
648 length = sdata.length;
649 break;
650 case DataBuffer.TYPE_INT:
651 int idata[] = (int[])inData;
652 pixel = idata[0];
653 length = idata.length;
654 break;
681 * this <code>ColorModel</code>.
682 * If this <code>transferType</code> is not supported, a
683 * <code>UnsupportedOperationException</code> will be
684 * thrown. Since
685 * <code>ColorModel</code> is an abstract class, any instance
686 * must be an instance of a subclass. Subclasses inherit the
687 * implementation of this method and if they don't override it, this
688 * method throws an exception if the subclass uses a
689 * <code>transferType</code> other than
690 * <code>DataBuffer.TYPE_BYTE</code>,
691 * <code>DataBuffer.TYPE_USHORT</code>, or
692 * <code>DataBuffer.TYPE_INT</code>.
693 * @param inData an array of pixel values
694 * @return the value of the green component of the specified pixel.
695 * @throws ClassCastException if <code>inData</code>
696 * is not a primitive array of type <code>transferType</code>
697 * @throws ArrayIndexOutOfBoundsException if
698 * <code>inData</code> is not large enough to hold a pixel value
699 * for this <code>ColorModel</code>
700 * @throws UnsupportedOperationException if this
701 * <code>tranferType</code> is not supported by this
702 * <code>ColorModel</code>
703 */
704 public int getGreen(Object inData) {
705 int pixel=0,length=0;
706 switch (transferType) {
707 case DataBuffer.TYPE_BYTE:
708 byte bdata[] = (byte[])inData;
709 pixel = bdata[0] & 0xff;
710 length = bdata.length;
711 break;
712 case DataBuffer.TYPE_USHORT:
713 short sdata[] = (short[])inData;
714 pixel = sdata[0] & 0xffff;
715 length = sdata.length;
716 break;
717 case DataBuffer.TYPE_INT:
718 int idata[] = (int[])inData;
719 pixel = idata[0];
720 length = idata.length;
721 break;
748 * value for this <code>ColorModel</code>.
749 * If this <code>transferType</code> is not supported, a
750 * <code>UnsupportedOperationException</code> will be
751 * thrown. Since
752 * <code>ColorModel</code> is an abstract class, any instance
753 * must be an instance of a subclass. Subclasses inherit the
754 * implementation of this method and if they don't override it, this
755 * method throws an exception if the subclass uses a
756 * <code>transferType</code> other than
757 * <code>DataBuffer.TYPE_BYTE</code>,
758 * <code>DataBuffer.TYPE_USHORT</code>, or
759 * <code>DataBuffer.TYPE_INT</code>.
760 * @param inData an array of pixel values
761 * @return the value of the blue component of the specified pixel.
762 * @throws ClassCastException if <code>inData</code>
763 * is not a primitive array of type <code>transferType</code>
764 * @throws ArrayIndexOutOfBoundsException if
765 * <code>inData</code> is not large enough to hold a pixel value
766 * for this <code>ColorModel</code>
767 * @throws UnsupportedOperationException if this
768 * <code>tranferType</code> is not supported by this
769 * <code>ColorModel</code>
770 */
771 public int getBlue(Object inData) {
772 int pixel=0,length=0;
773 switch (transferType) {
774 case DataBuffer.TYPE_BYTE:
775 byte bdata[] = (byte[])inData;
776 pixel = bdata[0] & 0xff;
777 length = bdata.length;
778 break;
779 case DataBuffer.TYPE_USHORT:
780 short sdata[] = (short[])inData;
781 pixel = sdata[0] & 0xffff;
782 length = sdata.length;
783 break;
784 case DataBuffer.TYPE_INT:
785 int idata[] = (int[])inData;
786 pixel = idata[0];
787 length = idata.length;
788 break;
1705 static boolean isLinearRGBspace(ColorSpace cs) {
1706 // Note: CMM.LINEAR_RGBspace will be null if the linear
1707 // RGB space has not been created yet.
1708 return (cs == CMSManager.LINEAR_RGBspace);
1709 }
1710
1711 static boolean isLinearGRAYspace(ColorSpace cs) {
1712 // Note: CMM.GRAYspace will be null if the linear
1713 // gray space has not been created yet.
1714 return (cs == CMSManager.GRAYspace);
1715 }
1716
1717 static byte[] getLinearRGB8TosRGB8LUT() {
1718 if (l8Tos8 == null) {
1719 l8Tos8 = new byte[256];
1720 float input, output;
1721 // algorithm for linear RGB to nonlinear sRGB conversion
1722 // is from the IEC 61966-2-1 International Standard,
1723 // Colour Management - Default RGB colour space - sRGB,
1724 // First Edition, 1999-10,
1725 // avaiable for order at http://www.iec.ch
1726 for (int i = 0; i <= 255; i++) {
1727 input = ((float) i) / 255.0f;
1728 if (input <= 0.0031308f) {
1729 output = input * 12.92f;
1730 } else {
1731 output = 1.055f * ((float) Math.pow(input, (1.0 / 2.4)))
1732 - 0.055f;
1733 }
1734 l8Tos8[i] = (byte) Math.round(output * 255.0f);
1735 }
1736 }
1737 return l8Tos8;
1738 }
1739
1740 static byte[] getsRGB8ToLinearRGB8LUT() {
1741 if (s8Tol8 == null) {
1742 s8Tol8 = new byte[256];
1743 float input, output;
1744 // algorithm from IEC 61966-2-1 International Standard
1745 for (int i = 0; i <= 255; i++) {
|
614 * this <code>ColorModel</code>.
615 * If this <code>transferType</code> is not supported, a
616 * <code>UnsupportedOperationException</code> will be
617 * thrown. Since
618 * <code>ColorModel</code> is an abstract class, any instance
619 * must be an instance of a subclass. Subclasses inherit the
620 * implementation of this method and if they don't override it, this
621 * method throws an exception if the subclass uses a
622 * <code>transferType</code> other than
623 * <code>DataBuffer.TYPE_BYTE</code>,
624 * <code>DataBuffer.TYPE_USHORT</code>, or
625 * <code>DataBuffer.TYPE_INT</code>.
626 * @param inData an array of pixel values
627 * @return the value of the red component of the specified pixel.
628 * @throws ClassCastException if <code>inData</code>
629 * is not a primitive array of type <code>transferType</code>
630 * @throws ArrayIndexOutOfBoundsException if
631 * <code>inData</code> is not large enough to hold a pixel value
632 * for this <code>ColorModel</code>
633 * @throws UnsupportedOperationException if this
634 * <code>transferType</code> is not supported by this
635 * <code>ColorModel</code>
636 */
637 public int getRed(Object inData) {
638 int pixel=0,length=0;
639 switch (transferType) {
640 case DataBuffer.TYPE_BYTE:
641 byte bdata[] = (byte[])inData;
642 pixel = bdata[0] & 0xff;
643 length = bdata.length;
644 break;
645 case DataBuffer.TYPE_USHORT:
646 short sdata[] = (short[])inData;
647 pixel = sdata[0] & 0xffff;
648 length = sdata.length;
649 break;
650 case DataBuffer.TYPE_INT:
651 int idata[] = (int[])inData;
652 pixel = idata[0];
653 length = idata.length;
654 break;
681 * this <code>ColorModel</code>.
682 * If this <code>transferType</code> is not supported, a
683 * <code>UnsupportedOperationException</code> will be
684 * thrown. Since
685 * <code>ColorModel</code> is an abstract class, any instance
686 * must be an instance of a subclass. Subclasses inherit the
687 * implementation of this method and if they don't override it, this
688 * method throws an exception if the subclass uses a
689 * <code>transferType</code> other than
690 * <code>DataBuffer.TYPE_BYTE</code>,
691 * <code>DataBuffer.TYPE_USHORT</code>, or
692 * <code>DataBuffer.TYPE_INT</code>.
693 * @param inData an array of pixel values
694 * @return the value of the green component of the specified pixel.
695 * @throws ClassCastException if <code>inData</code>
696 * is not a primitive array of type <code>transferType</code>
697 * @throws ArrayIndexOutOfBoundsException if
698 * <code>inData</code> is not large enough to hold a pixel value
699 * for this <code>ColorModel</code>
700 * @throws UnsupportedOperationException if this
701 * <code>transferType</code> is not supported by this
702 * <code>ColorModel</code>
703 */
704 public int getGreen(Object inData) {
705 int pixel=0,length=0;
706 switch (transferType) {
707 case DataBuffer.TYPE_BYTE:
708 byte bdata[] = (byte[])inData;
709 pixel = bdata[0] & 0xff;
710 length = bdata.length;
711 break;
712 case DataBuffer.TYPE_USHORT:
713 short sdata[] = (short[])inData;
714 pixel = sdata[0] & 0xffff;
715 length = sdata.length;
716 break;
717 case DataBuffer.TYPE_INT:
718 int idata[] = (int[])inData;
719 pixel = idata[0];
720 length = idata.length;
721 break;
748 * value for this <code>ColorModel</code>.
749 * If this <code>transferType</code> is not supported, a
750 * <code>UnsupportedOperationException</code> will be
751 * thrown. Since
752 * <code>ColorModel</code> is an abstract class, any instance
753 * must be an instance of a subclass. Subclasses inherit the
754 * implementation of this method and if they don't override it, this
755 * method throws an exception if the subclass uses a
756 * <code>transferType</code> other than
757 * <code>DataBuffer.TYPE_BYTE</code>,
758 * <code>DataBuffer.TYPE_USHORT</code>, or
759 * <code>DataBuffer.TYPE_INT</code>.
760 * @param inData an array of pixel values
761 * @return the value of the blue component of the specified pixel.
762 * @throws ClassCastException if <code>inData</code>
763 * is not a primitive array of type <code>transferType</code>
764 * @throws ArrayIndexOutOfBoundsException if
765 * <code>inData</code> is not large enough to hold a pixel value
766 * for this <code>ColorModel</code>
767 * @throws UnsupportedOperationException if this
768 * <code>transferType</code> is not supported by this
769 * <code>ColorModel</code>
770 */
771 public int getBlue(Object inData) {
772 int pixel=0,length=0;
773 switch (transferType) {
774 case DataBuffer.TYPE_BYTE:
775 byte bdata[] = (byte[])inData;
776 pixel = bdata[0] & 0xff;
777 length = bdata.length;
778 break;
779 case DataBuffer.TYPE_USHORT:
780 short sdata[] = (short[])inData;
781 pixel = sdata[0] & 0xffff;
782 length = sdata.length;
783 break;
784 case DataBuffer.TYPE_INT:
785 int idata[] = (int[])inData;
786 pixel = idata[0];
787 length = idata.length;
788 break;
1705 static boolean isLinearRGBspace(ColorSpace cs) {
1706 // Note: CMM.LINEAR_RGBspace will be null if the linear
1707 // RGB space has not been created yet.
1708 return (cs == CMSManager.LINEAR_RGBspace);
1709 }
1710
1711 static boolean isLinearGRAYspace(ColorSpace cs) {
1712 // Note: CMM.GRAYspace will be null if the linear
1713 // gray space has not been created yet.
1714 return (cs == CMSManager.GRAYspace);
1715 }
1716
1717 static byte[] getLinearRGB8TosRGB8LUT() {
1718 if (l8Tos8 == null) {
1719 l8Tos8 = new byte[256];
1720 float input, output;
1721 // algorithm for linear RGB to nonlinear sRGB conversion
1722 // is from the IEC 61966-2-1 International Standard,
1723 // Colour Management - Default RGB colour space - sRGB,
1724 // First Edition, 1999-10,
1725 // available for order at http://www.iec.ch
1726 for (int i = 0; i <= 255; i++) {
1727 input = ((float) i) / 255.0f;
1728 if (input <= 0.0031308f) {
1729 output = input * 12.92f;
1730 } else {
1731 output = 1.055f * ((float) Math.pow(input, (1.0 / 2.4)))
1732 - 0.055f;
1733 }
1734 l8Tos8[i] = (byte) Math.round(output * 255.0f);
1735 }
1736 }
1737 return l8Tos8;
1738 }
1739
1740 static byte[] getsRGB8ToLinearRGB8LUT() {
1741 if (s8Tol8 == null) {
1742 s8Tol8 = new byte[256];
1743 float input, output;
1744 // algorithm from IEC 61966-2-1 International Standard
1745 for (int i = 0; i <= 255; i++) {
|