示例#1
0
 public int getTextureId()
 {
     if (textureId == 0)
     {
         textureId = GraphicManager.createGLTexture(this);
     }
     return(textureId);
 }
示例#2
0
        public Bitmap getCreatureBitmap()
        {
            byte TRANSPARENT_COLOR = 0x11;

            int Width  = 32;
            int Height = 32;

            Bitmap canvas = new Bitmap(Width, Height, Img.PixelFormat.Format24bppRgb);

            Graphics g = Graphics.FromImage(canvas);

            for (int cx = 0; cx != this.width; cx++)
            {
                for (int cy = 0; cy != this.height; cy++)
                {
                    int texnum = getSpriteID(cx, cy,
                                             2,
                                             null,
                                             0
                                             );

                    Bitmap bmp = GraphicManager.getBitmap(GraphicManager.GetRGBData(spriteList[texnum]),
                                                          Img.PixelFormat.Format24bppRgb, 32, 32);

                    bmp.MakeTransparent(Color.FromArgb(TRANSPARENT_COLOR,
                                                       TRANSPARENT_COLOR, TRANSPARENT_COLOR));

                    if (width > 1 && height > 1)
                    {
                        g.DrawImage(bmp, new Rectangle(
                                        Math.Max(32 / this.width - cx * 32 / this.width, 0),
                                        Math.Max(32 / this.height - cy * 32 / this.height, 0),
                                        bmp.Width / this.width, bmp.Height / this.height));
                    }
                    else if (width > 1)
                    {
                        g.DrawImage(bmp, new Rectangle(
                                        Math.Max(32 / this.width - cx * 32 / this.width, 0),
                                        8,
                                        bmp.Width / this.width, bmp.Height / this.width));
                    }
                    else if (height > 1)
                    {
                        g.DrawImage(bmp, new Rectangle(
                                        8,
                                        Math.Max(32 / this.height - cy * 32 / this.height, 0),
                                        bmp.Width / this.height, bmp.Height / this.height));
                    }
                    else
                    {
                        g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
                    }
                }
            }

            g.Save();
            return(canvas);
        }