Slight speedup/separation of methods

This commit is contained in:
Kurt
2015-11-16 21:01:44 -08:00
parent 9619e4febf
commit efd4f12e81

View File

@@ -1010,18 +1010,7 @@ public byte[] Write()
public Bitmap Preview(int s, int ColorShift)
{
byte[] bmpData = new byte[4 * Width * Height * s * s];
for (int i = 0; i < Area; i++)
{
int X = i%40;
int Y = i/40;
uint colorValue = Tiles[i] == 0x01000021
? 0xFF000000
: (RNG.Forward32(Tiles[i], ColorShift) | 0xFF000000);
for (int x = 0; x < s * s; x++)
BitConverter.GetBytes(colorValue).CopyTo(bmpData, 4 * (((Y * s + x / s) * Width * s) + (X * s + x % s)));
}
byte[] bmpData = BytePreview(s, ColorShift);
Bitmap b = new Bitmap(Width * s, Height * s, PixelFormat.Format32bppArgb);
BitmapData bData = b.LockBits(new Rectangle(0, 0, Width * s, Height * s), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
System.Runtime.InteropServices.Marshal.Copy(bmpData, 0, bData.Scan0, bmpData.Length);
@@ -1029,6 +1018,23 @@ public Bitmap Preview(int s, int ColorShift)
return b;
}
public byte[] BytePreview(int s, int ColorShift)
{
byte[] bmpData = new byte[4 * Width * Height * s * s];
for (int i = 0; i < Area; i++)
{
int X = i % 40;
int Y = i / 40;
uint colorValue = Tiles[i] == 0x01000021
? 0xFF000000
: (RNG.Forward32(Tiles[i], ColorShift) | 0xFF000000);
byte[] pixel = BitConverter.GetBytes(colorValue);
for (int x = 0; x < s * s; x++)
pixel.CopyTo(bmpData, 4 * (((Y * s + x / s) * Width * s) + (X * s + x % s)));
}
return bmpData;
}
}
public string Unk2String()