Ejemplo n.º 1
0
        /// <summary> Sets the atlas bitmap that animation frames are contained within. </summary>
        void SetAtlas(Bitmap bmp)
        {
            if (!FastBitmap.CheckFormat(bmp.PixelFormat))
            {
                game.Drawer2D.ConvertTo32Bpp(ref bmp);
            }

            this.animBmp = bmp;
            animsBuffer  = new FastBitmap(bmp, true, true);
        }
        void SetFontBitmap(Game game, Stream stream)
        {
            Bitmap bmp = Platform.ReadBmp(stream);

            if (!FastBitmap.CheckFormat(bmp.PixelFormat))
            {
                game.Drawer2D.ConvertTo32Bpp(ref bmp);
            }
            game.Drawer2D.SetFontBitmap(bmp);
            game.Events.RaiseChatFontChanged();
        }
Ejemplo n.º 3
0
		void UpdateTexture( ref int texId, Stream stream, bool setSkinType ) {
			game.Graphics.DeleteTexture( ref texId );
			using( Bitmap bmp = new Bitmap( stream ) ) {
				if( setSkinType )
					game.DefaultPlayerSkinType = Utils.GetSkinType( bmp );
				
				if( !FastBitmap.CheckFormat( bmp.PixelFormat ) ) {
					using( Bitmap bmp32 = game.Drawer2D.ConvertTo32Bpp( bmp ) )
						texId = game.Graphics.CreateTexture( bmp32 );
				} else {
					texId = game.Graphics.CreateTexture( bmp );
				}
			}
		}
Ejemplo n.º 4
0
 /// <summary> Creates a new native texture with the specified dimensions and using the
 /// image data encapsulated by the Bitmap instance. </summary>
 /// <remarks> Note that should make every effort you can to ensure that the dimensions of the bitmap
 /// are powers of two, because otherwise they will not display properly on certain graphics cards.	<br/>
 /// This method returns -1 if the input image is not a 32bpp format. </remarks>
 public int CreateTexture(Bitmap bmp)
 {
     if (!FastBitmap.CheckFormat(bmp.PixelFormat))
     {
         string line2 = String.Format("input bitmap was not 32bpp, it was {0}",
                                      bmp.PixelFormat);
         ErrorHandler.LogError("IGraphicsApi.CreateTexture()",
                               Environment.NewLine + line2 +
                               Environment.NewLine + Environment.StackTrace);
         return(-1);
     }
     else
     {
         Rectangle  rec   = new Rectangle(0, 0, bmp.Width, bmp.Height);
         BitmapData data  = bmp.LockBits(rec, ImageLockMode.ReadOnly, bmp.PixelFormat);
         int        texId = CreateTexture(data.Width, data.Height, data.Scan0);
         bmp.UnlockBits(data);
         return(texId);
     }
 }
Ejemplo n.º 5
0
        protected void CheckSkin()
        {
            DownloadedItem item;

            game.AsyncDownloader.TryGetItem(SkinIdentifier, out item);
            if (item != null && item.Data != null)
            {
                Bitmap bmp = (Bitmap)item.Data;
                game.Graphics.DeleteTexture(ref TextureId);
                if (!FastBitmap.CheckFormat(bmp.PixelFormat))
                {
                    game.Drawer2D.ConvertTo32Bpp(ref bmp);
                }
                uScale = 1; vScale = 1;
                EnsurePow2(ref bmp);

                try {
                    SkinType = Utils.GetSkinType(bmp);
                    if (Model is HumanoidModel)
                    {
                        ClearHat(bmp, SkinType);
                    }
                    TextureId    = game.Graphics.CreateTexture(bmp);
                    MobTextureId = -1;

                    // Custom mob textures.
                    if (Utils.IsUrlPrefix(SkinName, 0) && item.TimeAdded > lastModelChange)
                    {
                        MobTextureId = TextureId;
                    }
                } catch (NotSupportedException) {
                    ResetSkin(bmp);
                }
                bmp.Dispose();
            }
        }