예제 #1
0
        /// <summary>
        /// Converts the specified byte array representation of an Adobe marker to its <see cref="AdobeMarker"/> equivalent and
        /// returns a value that indicates whether the conversion succeeded.
        /// </summary>
        /// <param name="bytes">The byte array containing metadata to parse</param>
        /// <param name="marker">The marker to return.</param>
        public static bool TryParse(byte[] bytes, out AdobeMarker marker)
        {
            if (ProfileResolver.IsProfile(bytes, ProfileResolver.AdobeMarker))
            {
                short dctEncodeVersion = (short)((bytes[5] << 8) | bytes[6]);
                short app14Flags0      = (short)((bytes[7] << 8) | bytes[8]);
                short app14Flags1      = (short)((bytes[9] << 8) | bytes[10]);
                byte  colorTransform   = bytes[11];

                marker = new AdobeMarker(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform);
                return(true);
            }

            marker = default(AdobeMarker);
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Converts the specified byte array representation of an JFIF marker to its <see cref="JFifMarker"/> equivalent and
        /// returns a value that indicates whether the conversion succeeded.
        /// </summary>
        /// <param name="bytes">The byte array containing metadata to parse</param>
        /// <param name="marker">The marker to return.</param>
        public static bool TryParse(byte[] bytes, out JFifMarker marker)
        {
            if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker))
            {
                byte  majorVersion = bytes[5];
                byte  minorVersion = bytes[6];
                byte  densityUnits = bytes[7];
                short xDensity     = (short)((bytes[8] << 8) | bytes[9]);
                short yDensity     = (short)((bytes[10] << 8) | bytes[11]);

                if (xDensity > 0 && yDensity > 0)
                {
                    marker = new JFifMarker(majorVersion, minorVersion, densityUnits, xDensity, yDensity);
                    return(true);
                }
            }

            marker = default(JFifMarker);
            return(false);
        }