Ejemplo n.º 1
0
        private void DrawSpriteResource(Icon icon, int orderIndex, Vector2f position)
        {
            int     resourceId = icon.GetResourceId(orderIndex);
            Texture texture    = GetTexture(resourceId);
            Sprite  sprite     = new Sprite(texture);
            ColorB  color      = icon.GetColor(orderIndex);

            sprite.Color = new Color(color.R, color.G, color.B, color.A);

            sprite.Position = position;
            _renderReceiver.DrawSprite(sprite);
        }
Ejemplo n.º 2
0
        public Bitmap GetEditorImage(TileObject instance)
        {
            Icon editorIcon = instance.EditorIcon;

            if (editorIcon == null)
            {
                return(null);
            }

            Texture texture = GetTexture(editorIcon.GetResourceId(0));

            if (texture == null)
            {
                return(null);
            }
            Image image = texture.CopyToImage();

            byte[] pixels = image.Pixels;

            int width  = (int)image.Size.X;
            int height = (int)image.Size.Y;

            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            var        boundsRect = new Rectangle(0, 0, width, height);
            BitmapData bmpData    = bmp.LockBits(boundsRect,
                                                 ImageLockMode.WriteOnly,
                                                 bmp.PixelFormat);

            IntPtr ptr = bmpData.Scan0;

            int bytes     = bmpData.Stride * bmp.Height;
            var rgbValues = new byte[bytes];

            Array.Copy(pixels, 0, rgbValues, 0, pixels.Length);

            Marshal.Copy(rgbValues, 0, ptr, bytes);
            bmp.UnlockBits(bmpData);
            return(bmp);
        }