示例#1
0
        /// <summary> Get the ICCProfile information JP2 ColorSpace</summary>
        /// <param name="csm">provides all necessary info about the colorspace
        /// </param>
        /// <returns> ICCMatrixBasedInputProfile for 3 component input and
        /// ICCMonochromeInputProfile for a 1 component source.  Returns
        /// null if exceptions were encountered.
        /// </returns>
        /// <exception cref="ColorSpaceException">
        /// </exception>
        /// <exception cref="ICCProfileException">
        /// </exception>
        /// <exception cref="IllegalArgumentException">
        /// </exception>
        private RestrictedICCProfile getICCProfile(CSJ2K.Color.ColorSpace csm)
        {
            switch (ncomps)
            {
            case 1:
                icc  = ICCMonochromeInputProfile.createInstance(csm);
                ricc = icc.parse();
                if (ricc.Type != RestrictedICCProfile.kMonochromeInput)
                {
                    throw new System.ArgumentException("wrong ICCProfile type" + " for image");
                }
                break;

            case 3:
                icc  = ICCMatrixBasedInputProfile.createInstance(csm);
                ricc = icc.parse();
                if (ricc.Type != RestrictedICCProfile.kThreeCompInput)
                {
                    throw new System.ArgumentException("wrong ICCProfile type" + " for image");
                }
                break;

            default:
                throw new System.ArgumentException("illegal number of " + "components (" + ncomps + ") in image");
            }
            return(ricc);
        }
示例#2
0
        /// <summary> Parse this ICCProfile into a RestrictedICCProfile
        /// which is appropriate to the data in this profile.
        /// Either a MonochromeInputRestrictedProfile or
        /// MatrixBasedRestrictedProfile is returned
        /// </summary>
        /// <returns> RestrictedICCProfile
        /// </returns>
        /// <exception cref="ICCProfileInvalidException">no curve data
        /// </exception>
        public virtual RestrictedICCProfile parse()
        {
            // The next step is to determine which Restricted ICC type is used by this profile.
            // Unfortunately, the only way to do this is to look through the tag table for
            // the tags required by the two types.

            // First look for the gray TRC tag. If the profile is indeed an input profile, and this
            // tag exists, then the profile is a Monochrome Input profile

            ICCCurveType grayTag = (ICCCurveType)tags[(System.Int32)kdwGrayTRCTag];

            if (grayTag != null)
            {
                return(RestrictedICCProfile.createInstance(grayTag));
            }

            // If it wasn't a Monochrome Input profile, look for the Red Colorant tag. If that
            // tag is found and the profile is indeed an input profile, then this profile is
            // a Three-Component Matrix-Based Input profile

            ICCCurveType rTRCTag = (ICCCurveType)tags[(System.Int32)kdwRedTRCTag];


            if (rTRCTag != null)
            {
                ICCCurveType gTRCTag      = (ICCCurveType)tags[(System.Int32)kdwGreenTRCTag];
                ICCCurveType bTRCTag      = (ICCCurveType)tags[(System.Int32)kdwBlueTRCTag];
                ICCXYZType   rColorantTag = (ICCXYZType)tags[(System.Int32)kdwRedColorantTag];
                ICCXYZType   gColorantTag = (ICCXYZType)tags[(System.Int32)kdwGreenColorantTag];
                ICCXYZType   bColorantTag = (ICCXYZType)tags[(System.Int32)kdwBlueColorantTag];
                return(RestrictedICCProfile.createInstance(rTRCTag, gTRCTag, bTRCTag, rColorantTag, gColorantTag, bColorantTag));
            }

            throw new ICCProfileInvalidException("curve data not found in profile");
        }
示例#3
0
        /// <summary> Ctor which creates an ICCProfile for the image and initializes
        /// all data objects (input, working, output).
        ///
        /// </summary>
        /// <param name="src">-- Source of image data
        /// </param>
        /// <param name="csm">-- provides colorspace info
        ///
        /// </param>
        /// <exception cref="IOException">
        /// </exception>
        /// <exception cref="ICCProfileException">
        /// </exception>
        /// <exception cref="IllegalArgumentException">
        /// </exception>
        protected internal ICCProfiler(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap) : base(src, csMap)
        {
            initialize();

            iccp = getICCProfile(csMap);
            if (ncomps == 1)
            {
                xform = new MonochromeTransformTosRGB(iccp, maxValueArray[0], shiftValueArray[0]);
            }
            else
            {
                xform = new MatrixBasedTransformTosRGB(iccp, maxValueArray, shiftValueArray);
            }

            /* end ICCProfiler ctor */
        }
示例#4
-1
		/// <summary> Ctor which creates an ICCProfile for the image and initializes
		/// all data objects (input, working, output).
		/// 
		/// </summary>
		/// <param name="src">-- Source of image data
		/// </param>
		/// <param name="csm">-- provides colorspace info
		/// 
		/// </param>
		/// <exception cref="IOException">
		/// </exception>
		/// <exception cref="ICCProfileException">
		/// </exception>
		/// <exception cref="IllegalArgumentException">
		/// </exception>
		protected internal ICCProfiler(BlkImgDataSrc src, CSJ2K.Color.ColorSpace csMap):base(src, csMap)
		{
			initialize();
			
			iccp = getICCProfile(csMap);
			if (ncomps == 1)
			{
				xform = new MonochromeTransformTosRGB(iccp, maxValueArray[0], shiftValueArray[0]);
			}
			else
			{
				xform = new MatrixBasedTransformTosRGB(iccp, maxValueArray, shiftValueArray);
			}
			
			/* end ICCProfiler ctor */
		}
示例#5
-1
		/// <summary> Get the ICCProfile information JP2 ColorSpace</summary>
		/// <param name="csm">provides all necessary info about the colorspace
		/// </param>
		/// <returns> ICCMatrixBasedInputProfile for 3 component input and
		/// ICCMonochromeInputProfile for a 1 component source.  Returns
		/// null if exceptions were encountered.
		/// </returns>
		/// <exception cref="ColorSpaceException">
		/// </exception>
		/// <exception cref="ICCProfileException">
		/// </exception>
		/// <exception cref="IllegalArgumentException">
		/// </exception>
		private RestrictedICCProfile getICCProfile(CSJ2K.Color.ColorSpace csm)
		{
			
			switch (ncomps)
			{
				
				case 1: 
					icc = ICCMonochromeInputProfile.createInstance(csm);
					ricc = icc.parse();
					if (ricc.Type != RestrictedICCProfile.kMonochromeInput)
						throw new System.ArgumentException("wrong ICCProfile type" + " for image");
					break;
				
				case 3: 
					icc = ICCMatrixBasedInputProfile.createInstance(csm);
					ricc = icc.parse();
					if (ricc.Type != RestrictedICCProfile.kThreeCompInput)
						throw new System.ArgumentException("wrong ICCProfile type" + " for image");
					break;
				
				default: 
					throw new System.ArgumentException("illegal number of " + "components (" + ncomps + ") in image");
				
			}
			return ricc;
		}