public void SaveToImageSlices(DX11Game game, DirectoryInfo dir) { for (int i = 0; i < Resource.Description.Depth; i++) { var tex2d = GPUTexture.CreateCPUWritable(game, Resource.Description.Width, Resource.Description.Height, Format.R8G8B8A8_UNorm); Resource.Device.ImmediateContext.CopySubresourceRegion(Resource, 0, new ResourceRegion(0, 0, i, Resource.Description.Width, Resource.Description.Height, i + 1), tex2d.Resource, 0, 0, 0, 0); Texture2D.SaveTextureToFile(game.Device.ImmediateContext, tex2d.Resource, ImageFileFormat.Bmp, dir.FullName + "/" + i + ".bmp"); } }
public TextTexture(DX11Game game, int width, int height) { bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); GPUTexture = GPUTexture.CreateCPUWritable(game, bmp.Width, bmp.Height, Format.B8G8R8A8_UNorm); SetFont("Verdana", 10); //Then you create a StringFormat object to specify text alignments etc. sf = StringFormat.GenericDefault; //Then create a graphics object to be able to write in the bmp image g = System.Drawing.Graphics.FromImage(bmp); g.PageUnit = GraphicsUnit.Pixel; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; Clear(); }
public void TestDrawingToD3D11Conversion() { var bmp = createBitmap(); var game = new DX11Game(); game.InitDirectX(); var tex = GPUTexture.CreateCPUWritable(game, bmp.Width, bmp.Height, Format.B8G8R8A8_UNorm); var convert = new DrawingToD3D11Conversion(); convert.WriteBitmapToTexture(bmp, tex); game.GameLoopEvent += delegate { game.TextureRenderer.Draw(tex.View, Vector2.Zero, new Vector2(100, 100)); }; game.Run(); }