Exemple #1
0
        public override Image[] Load(string assetName)
        {
            var stream = FileLoader.GetStream(assetName);

            byte[] bytes  = null;
            var    width  = 0;
            var    height = 0;

            if (Png.IsPng(stream))
            {
                stream.Position = 0;
                var png         = new Png();
                var imageOutput = new PngImageOutput();
                png.read(stream, imageOutput);
                width  = png.ihdr.width;
                height = png.ihdr.height;
                bytes  = imageOutput.Bytes;
            }

            var frame = ContentManager.CreateAssetPart <Image>();

            frame.Width  = width;
            frame.Height = height;
            if (null != bytes)
            {
                frame.ImageContext.SetFrame(bytes);
            }

            return(new[] { frame });
        }
 /// <summary>
 /// Loads a png from the specified stream, optionally with color0=transparent
 /// </summary>
 Image LoadPNG(GraphicsDevice device, Stream stream, bool color0)
 {
     pr2.sharppng.Png png = new pr2.sharppng.Png();
     PngImageOutput imageOutput = new PngImageOutput(device, color0);
     png.read(stream, imageOutput);
     return new Image(GameEngine.Game.Device, imageOutput.tex);
 }