public static uint[] LoadRawL32(string filename, out int width, out int height) { Image tmpimg = new Image(filename); Debug.Assert(tmpimg.BytesPerPixel == 4); width = tmpimg.Width; height = tmpimg.Height; uint[] buffer = new uint[width * height]; int offset = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { buffer[offset] = (uint)tmpimg.GetRawPixel(x, y); offset++; } } tmpimg.Dispose(); return(buffer); }
/// <summary> /// Copy pixels in from a source image. /// </summary> /// <param name="src"></param> /// <param name="sx"></param> /// <param name="sz"></param> /// <param name="size"></param> protected virtual void CopyFromImage(Image src, int sx, int sz, int size) { // loop over all pixels, converting to the world's height range while // copying. for (int z = 0; z < size; z++) { for (int x = 0; x < size; x++) { uint raw = src.GetRawPixel(x + sx, z + sz); SetValue(x, z, raw); } } dirty = true; }
public static uint[] LoadRawL32(string filename, out int width, out int height) { Image tmpimg = new Image(filename); Debug.Assert(tmpimg.BytesPerPixel == 4); width = tmpimg.Width; height = tmpimg.Height; uint[] buffer = new uint[width * height]; int offset = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { buffer[offset] = (uint)tmpimg.GetRawPixel(x, y); offset++; } } tmpimg.Dispose(); return buffer; }