コード例 #1
0
ファイル: BasicWrite.cs プロジェクト: digimarc-corp/ntiff
        public void CanFinalizeShortTag()
        {
            var artist = "Bob";
            var tag    = new Tag <char>
            {
                DataType = TagDataType.ASCII,
                ID       = (ushort)BaselineTags.Artist,
                Length   = (uint)artist.Length + 1,
                Values   = artist.ToASCIIArray()
            };

            using (var stream = new TiffStreamWriter())
            {
                stream.WriteDWord(1);
                stream.WriteTagPlaceholder(tag);
                stream.FinalizeTag(tag);

                var data = stream.ToArray();

                Assert.Equal(4u, tag.Offset);
                Assert.Equal(4u, tag.Length);
                Assert.Equal(16, data.Length);
                Assert.Equal(artist, Encoding.ASCII.GetString(tag.RawValue).Trim('\0'));
            }
        }
コード例 #2
0
ファイル: BasicWrite.cs プロジェクト: digimarc-corp/ntiff
        public void CanWriteTagPlaceholder()
        {
            var tag = new Tag
            {
                DataType = TagDataType.Short,
                ID       = (ushort)BaselineTags.BitsPerSample,
                Length   = 1
            };

            using (var stream = new TiffStreamWriter())
            {
                stream.WriteTagPlaceholder(tag);

                var data = stream.ToArray();
                Assert.True(data.SequenceEqual(new byte[] { 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
            }

            using (var stream = new TiffStreamWriter(forceBigEndian: true))
            {
                stream.WriteTagPlaceholder(tag);

                var data = stream.ToArray();
                Assert.True(data.SequenceEqual(new byte[] { 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }));
            }
        }
コード例 #3
0
ファイル: BasicWrite.cs プロジェクト: digimarc-corp/ntiff
        public void CanFinalizeLongTag()
        {
            var artist = "Ansel Adams";
            var tag    = new Tag <char>
            {
                DataType = TagDataType.ASCII,
                ID       = (ushort)BaselineTags.Artist,
                Length   = (uint)artist.Length + 1,
                Values   = artist.ToASCIIArray()
            };

            using (var stream = new TiffStreamWriter())
            {
                stream.WriteDWord(1);
                stream.WriteTagPlaceholder(tag);
                stream.FinalizeTag(tag);

                var data = stream.ToArray();

                Assert.Equal(4u, tag.Offset);
                Assert.Equal(12u, tag.Length);
                Assert.Equal(28, data.Length);
                Assert.True(tag.RawValue.SequenceEqual(BitConverter.GetBytes(16u)));
            }
        }
コード例 #4
0
ファイル: BasicWrite.cs プロジェクト: digimarc-corp/ntiff
        public void WriteTagPlaceholderUpdatesOffset()
        {
            var tag = new Tag
            {
                DataType = TagDataType.ASCII,
                ID       = (ushort)BaselineTags.Artist,
                Length   = 1
            };

            using (var stream = new TiffStreamWriter())
            {
                stream.WriteTagPlaceholder(tag);
                stream.WriteTagPlaceholder(tag);

                Assert.Equal(24, stream.Length);
                Assert.Equal(12u, tag.Offset);
            }
        }