Exemplo n.º 1
0
        public static ImageData Load(Stream s)
        {
            ImageData    img;
            BinaryReader br    = new BinaryReader(s);
            var          magic = br.ReadUInt32();

            s.Position = 0;
            if (magic == 0xE0FFD8FF)
            {
                System.Drawing.Bitmap image = new System.Drawing.Bitmap(s);
                img = FromBitmap(image);
            }
            else if (magic == 0x20534444)
            {
                IImage image = Dds.Create(s);
                img = FromPfimImg(image);
            }
            //tga image
            else
            {
                IImage image = Targa.Create(s);
                img = FromPfimImg(image);
            }
            return(img);
        }
Exemplo n.º 2
0
 public int Pfim()
 {
     using (var image = Targa.Create(data, _pfimConfig))
     {
         return(image.BitsPerPixel);
     }
 }
Exemplo n.º 3
0
 public int TgaPfim()
 {
     using (var image = Targa.Create(this.data, this.pfimConfig))
     {
         return(image.Width);
     }
 }
Exemplo n.º 4
0
        public void ParseTargaTopLeftRleStride()
        {
            var data  = File.ReadAllBytes(Path.Combine("data", "DSCN1910_24bpp_uncompressed_10_2.tga"));
            var image = Targa.Create(data, new PfimConfig());

            Assert.Equal(461, image.Width);
        }
Exemplo n.º 5
0
        public void ParseTargaTopLeftStride()
        {
            var data  = File.ReadAllBytes(Path.Combine("data", "DSCN1910_24bpp_uncompressed_10_3.tga"));
            var image = Targa.Create(data, new PfimConfig());

            Assert.Equal(461, image.Width);
            Assert.True(image.Data[460 * 3] != 0 && image.Data[461 * 3 + 1] != 0 && image.Data[461 * 3 + 2] != 0);
        }
Exemplo n.º 6
0
            public TgaFrame(Stream stream)
            {
                using (var tga = Targa.Create(stream, new PfimConfig()))
                {
                    Size = FrameSize = new Size(tga.Width, tga.Height);
                    Data = tga.Data;
                    switch (tga.Format)
                    {
                    // SpriteFrameType refers to the channel byte order, which is reversed from the little-endian bit order
                    case ImageFormat.Rgba32: Type = SpriteFrameType.Bgra32; break;

                    case ImageFormat.Rgb24: Type = SpriteFrameType.Bgr24; break;

                    default: throw new InvalidDataException($"Unhandled ImageFormat {tga.Format}");
                    }
                }
            }