示例#1
0
        public override Texture newTexture(Pixmap pixmap, PixmapFormat format)
        {
            var rawPixmap = ((MonoGamePixmap)pixmap).toRawPixelsARGB();

            var texture = new Texture2D(_graphicsDevice, pixmap.getWidth(), pixmap.getHeight(), false, SurfaceFormat.Color);

            texture.SetData(rawPixmap);

            return(new MonoGameTexture(texture));
        }
示例#2
0
        public void draw(Pixmap pixmap, int x, int y)
        {
            var rawTexture = new UInt32[texture2D.Width * texture2D.Height];

            texture2D.GetData(rawTexture);
            for (var pixmapX = 0; pixmapX < pixmap.getWidth(); pixmapX++)
            {
                for (var pixmapY = 0; pixmapY < pixmap.getHeight(); pixmapY++)
                {
                    rawTexture[x + pixmapX + (y + pixmapY) * texture2D.Width] = (uint)pixmap.getPixel(pixmapX, pixmapY);
                }
            }
            texture2D.SetData(rawTexture);
        }
示例#3
0
        public Texture newTexture(Pixmap pixmap, PixmapFormat format)
        {
            var rawPixmap = pixmap.getPixels();

            SurfaceFormat destFormat;

            if (format == PixmapFormat.ALPHA)
            {
                destFormat = SurfaceFormat.Alpha8;
            }
            else if (format == PixmapFormat.RGBA8888)
            {
                destFormat = SurfaceFormat.ColorSRgb;
            }
            else
            {
                throw new ArgumentException("format not supported");
            }
            var texture = new Texture2D(_graphicsDevice, pixmap.getWidth(), pixmap.getHeight(), false, destFormat);

            texture.SetData(rawPixmap);

            return(new MonoGameTexture(texture));
        }
示例#4
0
 public void drawPixmap(Pixmap pixmap, int x, int y)
 {
     drawPixmap(pixmap, x, y, 0, 0, pixmap.getWidth(), pixmap.getHeight());
 }