protected void CreateImage(int width, int height) { string imgName = String.Format("_font_string_{0}", this.name); Axiom.Core.Texture fontTexture = null; if (Axiom.Core.TextureManager.Instance.HasResource(imgName)) { fontTexture = Axiom.Core.TextureManager.Instance.GetByName(imgName); chunkAtlas = AtlasManager.Instance.GetTextureAtlas(imgName); } else { fontTexture = Axiom.Core.TextureManager.Instance.LoadImage(imgName, null); chunkAtlas = AtlasManager.Instance.CreateAtlas(imgName, fontTexture); } System.Diagnostics.Debug.Assert(bitmap == null); if (dynamic) { bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); } else { bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); } CopyBitmapToTexture(bitmap, fontTexture); textDirty = true; }
protected void CopyBitmapToTexture(Bitmap fontBitmap, Axiom.Core.Texture fontTexture) { // save the image to a memory stream Stream stream = new MemoryStream(); // flip the image fontBitmap.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY); fontBitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); // Bitmap headers are 54 bytes.. skip them stream.Position = BitmapHeaderSize; loadImageMeter.Enter(); if (dynamic) { fontTexture.LoadRawData(stream, fontBitmap.Width, fontBitmap.Height, Axiom.Media.PixelFormat.R8G8B8); } else { fontTexture.LoadRawData(stream, fontBitmap.Width, fontBitmap.Height, Axiom.Media.PixelFormat.A8R8G8B8); } loadImageMeter.Exit(); }