Exemplo n.º 1
0
        public void MarkerHashCodeIsReplicable()
        {
            JFifMarker.TryParse(this.bytes, out var marker);
            JFifMarker.TryParse(this.bytes, out var marker2);

            Assert.True(marker.GetHashCode().Equals(marker2.GetHashCode()));
        }
Exemplo n.º 2
0
        public void MarkerHashCodeIsUnique()
        {
            JFifMarker.TryParse(this.bytes, out var marker);
            JFifMarker.TryParse(this.bytes2, out var marker2);

            Assert.False(marker.GetHashCode().Equals(marker2.GetHashCode()));
        }
Exemplo n.º 3
0
        public void MarkerInEqualityIsCorrect()
        {
            JFifMarker.TryParse(this.bytes, out var marker);
            JFifMarker.TryParse(this.bytes2, out var marker2);

            Assert.False(marker.Equals(marker2));
        }
Exemplo n.º 4
0
        public void MarkerIgnoresCorrectHeaderButInvalidDensities()
        {
            bool isJFif = JFifMarker.TryParse(this.bytes3, out var marker);

            Assert.False(isJFif);
            Assert.Equal(default(JFifMarker), marker);
        }
Exemplo n.º 5
0
        public void MarkerIgnoresIncorrectValue()
        {
            bool isJFif = JFifMarker.TryParse(new byte[] { 0, 0, 0, 0 }, out var marker);

            Assert.False(isJFif);
            Assert.Equal(default(JFifMarker), marker);
        }
Exemplo n.º 6
0
        public void MarkerReturnsCorrectParsedValue()
        {
            bool isJFif = JFifMarker.TryParse(this.bytes, out JFifMarker marker);

            Assert.True(isJFif);
            Assert.Equal(1, marker.MajorVersion);
            Assert.Equal(1, marker.MinorVersion);
            Assert.Equal(PixelResolutionUnit.PixelsPerInch, marker.DensityUnits);
            Assert.Equal(96, marker.XDensity);
            Assert.Equal(96, marker.YDensity);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Processes the application header containing the JFIF identifier plus extra data.
        /// </summary>
        /// <param name="remaining">The remaining bytes in the segment block.</param>
        private void ProcessApplicationHeaderMarker(int remaining)
        {
            if (remaining < 5)
            {
                this.InputProcessor.Skip(remaining);
                return;
            }

            const int MarkerLength = JFifMarker.Length;

            this.InputProcessor.ReadFull(this.Temp, 0, MarkerLength);
            remaining -= MarkerLength;

            this.isJFif = JFifMarker.TryParse(this.Temp, out this.jFif);

            if (remaining > 0)
            {
                this.InputProcessor.Skip(remaining);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Processes the application header containing the JFIF identifier plus extra data.
        /// </summary>
        /// <param name="remaining">The remaining bytes in the segment block.</param>
        private void ProcessApplicationHeaderMarker(int remaining)
        {
            if (remaining < 5)
            {
                // Skip the application header length
                this.InputStream.Skip(remaining);
                return;
            }

            this.InputStream.Read(this.temp, 0, JFifMarker.Length);
            remaining -= JFifMarker.Length;

            JFifMarker.TryParse(this.temp, out this.jFif);

            // TODO: thumbnail
            if (remaining > 0)
            {
                this.InputStream.Skip(remaining);
            }
        }