コード例 #1
0
        public void Identify_WithValidData_Works(byte[] data, int width, int height, TgaBitsPerPixel bitsPerPixel)
        {
            using var stream = new MemoryStream(data);

            IImageInfo  info    = Image.Identify(stream);
            TgaMetadata tgaData = info.Metadata.GetTgaMetadata();

            Assert.Equal(bitsPerPixel, tgaData.BitsPerPixel);
            Assert.Equal(width, info.Width);
            Assert.Equal(height, info.Height);
        }
コード例 #2
0
ファイル: TgaEncoderTests.cs プロジェクト: wilka/ImageSharp
        public void TgaEncoder_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bmpBitsPerPixel)
        {
            var options = new TgaEncoder();

            var testFile = TestFile.Create(imagePath);

            using (Image <Rgba32> input = testFile.CreateRgba32Image())
            {
                using (var memStream = new MemoryStream())
                {
                    input.Save(memStream, options);
                    memStream.Position = 0;
                    using (var output = Image.Load <Rgba32>(memStream))
                    {
                        TgaMetadata meta = output.Metadata.GetTgaMetadata();
                        Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel);
                    }
                }
            }
        }
コード例 #3
0
        public void Encode_WithCompression_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bmpBitsPerPixel)
        {
            var options = new TgaEncoder()
            {
                Compression = TgaCompression.RunLength
            };

            TestFile testFile = TestFile.Create(imagePath);

            using (Image <Rgba32> input = testFile.CreateRgba32Image())
            {
                using (var memStream = new MemoryStream())
                {
                    input.Save(memStream, options);
                    memStream.Position = 0;
                    using (Image <Rgba32> output = Image.Load <Rgba32>(memStream))
                    {
                        TgaMetadata meta = output.Metadata.GetFormatMetadata(TgaFormat.Instance);
                        Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TgaMetadata"/> class.
 /// </summary>
 /// <param name="other">The metadata to create an instance from.</param>
 private TgaMetadata(TgaMetadata other)
 {
     this.BitsPerPixel = other.BitsPerPixel;
 }