Exemple #1
0
        /// <summary>
        /// <para>Returns, in the blk argument, a block of image data containing the
        /// specifed rectangular area, in the specified component. The data is
        /// returned, as a copy of the internal data, therefore the returned data
        /// can be modified "in place".</para>
        ///
        /// <para>The rectangular area to return is specified by the 'ulx', 'uly', 'w'
        /// and 'h' members of the 'blk' argument, relative to the current
        /// tile. These members are not modified by this method. The 'offset' of
        /// the returned data is 0, and the 'scanw' is the same as the block's
        /// width. See the 'DataBlk' class.</para>
        ///
        /// <para>If the data array in 'blk' is 'null', then a new one is created. If
        /// the data array is not 'null' then it is reused, and it must be large
        /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
        /// or an 'IndexOutOfBoundsException' is thrown by the Java system.</para>
        ///
        /// <para>The returned data has its 'progressive' attribute set to that of the
        /// input data.</para>
        ///
        /// </summary>
        /// <param name="blk">Its coordinates and dimensions specify the area to
        /// return. If it contains a non-null data array, then it must have the
        /// correct dimensions. If it contains a null data array a new one is
        /// created. The fields in this object are modified to return the data.
        ///
        /// </param>
        /// <param name="c">The index of the component from which to get the data. Only 0
        /// and 3 are valid.
        ///
        /// </param>
        /// <returns> The requested DataBlk
        /// </returns>
        /// <seealso cref="getInternCompData">
        ///
        /// </seealso>
        public override DataBlk getCompData(DataBlk outblk, int c)
        {
            int    type   = outblk.DataType;
            double colors = Math.Pow(2, src.getNomRangeBits(c));
            double bitoff = colors * 0.375D;

            if (type == DataBlk.TYPE_INT)
            {
                DataBlkInt intblk = (DataBlkInt)src.getInternCompData(outblk, c);

                for (int i = 0; i < intblk.data_array.Length; i++)
                {
                    int tmp = intblk.data_array[i];

                    tmp += (int)(colors / 2);
                    tmp -= (int)bitoff;
                    tmp *= 2;
                    tmp -= (int)(colors / 2);

                    intblk.data_array[i] = tmp;
                }
                outblk = intblk;
            }
            else if (type == DataBlk.TYPE_FLOAT)
            {
                FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported e-sRGB DataType (float)");

                DataBlkFloat fltblk = (DataBlkFloat)src.getInternCompData(outblk, c);
                outblk = fltblk;
            }
            return(outblk);
        }
Exemple #2
0
        /// <summary> Read the header and tags into memory and verify
        /// that the correct type of profile is being used. for encoding.
        /// </summary>
        /// <param name="data">ICCProfile
        /// </param>
        /// <exception cref="ICCProfileInvalidException">for bad signature and class and bad type
        /// </exception>
        private void initProfile(byte[] data)
        {
            header = new ICCProfileHeader(data);
            tags   = ICCTagTable.createInstance(data);


            // Verify that the data pointed to by icc is indeed a valid profile
            // and that it is possibly of one of the Restricted ICC types. The simplest way to check
            // this is to verify that the profile signature is correct, that it is an input profile,
            // and that the PCS used is XYX.

            // However, a common error in profiles will be to create Monitor profiles rather
            // than input profiles. If this is the only error found, it's still useful to let this
            // go through with an error written to stderr.

            if (ProfileClass == kdwDisplayProfile)
            {
                string message = "NOTE!! Technically, this profile is a Display profile, not an"
                                 + " Input Profile, and thus is not a valid Restricted ICC profile."
                                 + " However, it is quite possible that this profile is usable as"
                                 + " a Restricted ICC profile, so this code will ignore this state"
                                 + " and proceed with processing.";

                FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, message);
            }

            if ((ProfileSignature != kdwProfileSignature) ||
                ((ProfileClass != kdwInputProfile) && (ProfileClass != kdwDisplayProfile)) || (PCSType != kdwXYZData))
            {
                throw new ICCProfileInvalidException();
            }
        }
Exemple #3
0
 /// <summary>General utility used by ctors </summary>
 private void  initialize()
 {
     if (ncomps != 1 && ncomps != 3)
     {
         System.String msg = "EsRgbColorSpaceMapper: e-sRGB transformation _not_ applied to " + ncomps + " component image";
         FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, msg);
         throw new ColorSpaceException(msg);
     }
 }