//tilesize is for if you want to skip every X pixels
//MinX and MinY are the top left of the square to rip
//fullwidth and fullheight are the width/height of the full image
//countx and county are the size of the image you want to rip
public static void GetArea(int fullwidth, int fullheight, int tilesize, int MinX, int MinY, int CountX, int CountY, BinaryReader heightmap, ref Color[] area)
{
byte bytedepth = 3;
int x = 0, z = 0;
int startpos = 1078 + (MinY * fullwidth) * bytedepth + (MinX * bytedepth);
for (z = 0; z < CountY; z++)
{
for (x = 0; x < CountX; x++)
{
int thispixel = z * CountX + x;
int seekpos = startpos
+ (z * (tilesize * bytedepth)) * fullwidth
+ x * (tilesize * bytedepth);
if (seekpos > 0 && seekpos < (fullheight * fullwidth) * bytedepth + 1078)
{
heightmap.BaseStream.Seek(seekpos, SeekOrigin.Begin);
area[thispixel] = new Color(heightmap.ReadByte(), heightmap.ReadByte(), heightmap.ReadByte());
area[thispixel] = new Color(area[thispixel].G,
area[thispixel].R,
area[thispixel].B);
}
else
area[thispixel] = Color.HotPink;
}
}
}