Ejemplo n.º 1
0
        public static UInt32 convertTo(PixmapFormat format, UInt32 colorRGBA8888)
        {
            if (format == PixmapFormat.RGBA8888)
            {
                return(colorRGBA8888);
            }
            else if (format == PixmapFormat.RGB565)
            {
                return(toRGB565(colorRGBA8888));
            }
            else if (format == PixmapFormat.RGB888)
            {
                return(toRGB888(colorRGBA8888));
            }
            else if (format == PixmapFormat.RGBA4444)
            {
                return(toRGBA4444(colorRGBA8888));
            }
            else if (format == PixmapFormat.ALPHA)
            {
                return(getAAsByte(colorRGBA8888));
            }
            else if (format == PixmapFormat.INTENSITY)
            {
                return(toIntensity(colorRGBA8888));
            }
            else if (format == PixmapFormat.LUMINANCE_ALPHA)
            {
                return(toLuminanceAlpha(colorRGBA8888));
            }

            return(0);
        }
Ejemplo n.º 2
0
 public MonoGamePixmap(int width, int height, PixmapFormat format)
 {
     _width    = width;
     _height   = height;
     _pixmap   = new UInt32[width, height];
     _setColor = new MonoGameColor(0, 0, 0, 255);
     _blending = PixmapBlending.NONE;
     _filter   = PixmapFilter.NEAREST_NEIGHBOUR;
     _format   = format;
 }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public static int getBytesPerPixel(PixmapFormat format)
        {
            var bytesPerPixel = 2;

            if (format == PixmapFormat.INTENSITY)
            {
                bytesPerPixel = 1;
            }
            else if (format == PixmapFormat.RGB888)
            {
                bytesPerPixel = 3;
            }
            else if (format == PixmapFormat.RGBA8888)
            {
                bytesPerPixel = 4;
            }

            return(bytesPerPixel);
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
 public static extern ref XImage XGetImage(IntPtr display, Window drawable, int x, int y,
                                           uint width, uint height, ulong plane_mask, PixmapFormat format);
Ejemplo n.º 7
0
 public AndroidPixmap(Bitmap bitmap, PixmapFormat format)
 {
     this.bitmap = bitmap;
     _format     = format;
 }
Ejemplo n.º 8
0
 public Pixmap newPixmap(int width, int height, PixmapFormat format)
 {
     return(new MonoGamePixmap(width, height, format));
 }
Ejemplo n.º 9
0
        public Texture newTexture(FileHandle fileHandle, PixmapFormat format)
        {
            var pixmap = newPixmap(fileHandle);

            return(newTexture(pixmap, pixmap.getFormat()));
        }
Ejemplo n.º 10
0
        public IPixmap NewPixmap(string fileName, PixmapFormat format)
        {
            Bitmap.Config config = null;
            if (format == PixmapFormat.RGB565)
            {
                config = Bitmap.Config.Rgb565;
            }
            else if (format == PixmapFormat.ARGB4444)
            {
                config = Bitmap.Config.Argb4444;
            }
            else
            {
                config = Bitmap.Config.Argb8888;
            }

            BitmapFactory.Options opt = new BitmapFactory.Options();
            opt.InPreferredConfig = config;

            Stream s      = null;
            Bitmap bitmap = null;

            try
            {
                s      = _am.Open(fileName);
                bitmap = BitmapFactory.DecodeStream(s);
                if (bitmap == null)
                {
                    throw new AndroidRuntimeException("Couldn't load bitmap from asset" + fileName);
                }
            }
            catch
            {
                throw new AndroidRuntimeException("Couldn't load bitmap from asset" + fileName);
            }
            finally
            {
                if (s != null)
                {
                    try
                    {
                        s.Close();
                    }
                    catch {}
                }
            }

            if (bitmap.GetConfig() == Bitmap.Config.Rgb565)
            {
                format = PixmapFormat.RGB565;
            }
            else if (bitmap.GetConfig() == Bitmap.Config.Argb4444)
            {
                format = PixmapFormat.ARGB4444;
            }
            else
            {
                format = PixmapFormat.ARGB8888;
            }

            return(new AndroidPixmap(bitmap, format));
        }