From 5adafd538ae98073127f890d8a3db13745e6b716 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 20 Oct 2007 00:09:07 +0000 Subject: * Fixed an issue whereby avatar chat distances were being calculated against the region corner due to a zero vector. * Bonus Commit: Fixed the Raster class in libTerrain. --- .../libTerrainBSD/Bitmap/Bitmap.cs | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD') diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs index 4f98af1..8359f8e 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs @@ -39,6 +39,11 @@ namespace libTerrain int h; Bitmap bmp; + /// + /// Creates a new Raster channel for use with bitmap or GDI functions + /// + /// Width in pixels + /// Height in pixels public Raster(int width, int height) { w = width; @@ -46,6 +51,10 @@ namespace libTerrain bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); } + /// + /// Converts a raster image to a channel by averaging the RGB values to a single 0..1 heightmap + /// + /// A libTerrain Channel public Channel ToChannel() { Channel chan = new Channel(bmp.Width, bmp.Height); @@ -63,12 +72,21 @@ namespace libTerrain return chan; } + /// + /// Draws a piece of text into the specified raster + /// + /// The text string to print + /// The font to use to draw the specified image + /// Font size (points) to use public void DrawText(string txt, string font, double size) { - Graphics gd = Graphics.FromImage(bmp); - //gd.DrawString(txt, + Rectangle area = new Rectangle(0, 0, 256, 256); + StringFormat sf = new StringFormat(); + sf.Alignment = StringAlignment.Center; + sf.LineAlignment = StringAlignment.Center; - + Graphics gd = Graphics.FromImage(bmp); + gd.DrawString(txt, new Font(font, (float)size), new SolidBrush(Color.White), area, sf); } } } -- cgit v1.1