29 #define SYSTEM_DRAWING
32 using System.Collections.Generic;
37 using System.Drawing.Imaging;
58 if (bmW == 0 || bmH == 0)
59 throw new Exception(
"SculptMap: bitmap has no data");
61 int numLodPixels = lod * lod;
63 bool smallMap = bmW * bmH <= numLodPixels;
64 bool needsScaling =
false;
83 throw new Exception(
"Exception in ScaleImage(): e: " + e.ToString());
101 for (
int y = 0; y <=
height; y++)
103 for (
int x = 0; x <=
width; x++)
108 c = bm.GetPixel(x <
width ? x : x - 1,
111 c = bm.GetPixel(x <
width ? x * 2 : x * 2 - 1,
112 y <
height ? y * 2 : y * 2 - 1);
124 throw new Exception(
"Caught exception processing byte arrays in SculptMap(): e: " + e.ToString());
131 public List<List<Coord>>
ToRows(
bool mirror)
136 List<List<Coord>> rows =
new List<List<Coord>>(numRows);
138 float pixScale = 1.0f / 255;
144 for (rowNdx = 0; rowNdx < numRows; rowNdx++)
146 List<Coord> row =
new List<Coord>(numCols);
147 for (colNdx = 0; colNdx < numCols; colNdx++)
162 private Bitmap ScaleImage(Bitmap srcImage,
int destWidth,
int destHeight)
165 Bitmap scaledImage =
new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
168 float xscale = srcImage.Width / destWidth;
169 float yscale = srcImage.Height / destHeight;
172 for (
int y = 0; y < destHeight; y++)
175 for (
int x = 0; x < destWidth; x++)
179 c = srcImage.GetPixel((int)(sx), (int)(sy));
180 scaledImage.SetPixel(x, y, Color.FromArgb(c.R, c.G, c.B));
182 catch (IndexOutOfRangeException)
SculptMap(Bitmap bm, int lod)
List< List< Coord > > ToRows(bool mirror)