wow, it works!

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1190 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
chrisf
2007-07-13 09:15:06 +00:00
parent bbbb25909a
commit d37bab15d0
16 changed files with 136 additions and 57 deletions

View File

@@ -7,12 +7,12 @@ namespace OpenRa.FileFormats
{
public static class BitmapBuilder
{
public static Bitmap FromBytes( byte[] imageBytes, int width, int height, Palette pal )
public static Bitmap FromBytes(byte[] imageBytes, Size size, Palette pal)
{
Bitmap bitmap = new Bitmap( width, height );
for( int x = 0 ; x < width ; x++ )
for( int y = 0 ; y < height ; y++ )
bitmap.SetPixel( x, y, pal.GetColor( imageBytes[ x + width * y ] ) );
Bitmap bitmap = new Bitmap(size.Width, size.Height);
for (int x = 0; x < size.Width; x++)
for (int y = 0; y < size.Height; y++)
bitmap.SetPixel(x, y, pal.GetColor(imageBytes[x + size.Width * y]));
return bitmap;
}

View File

@@ -42,6 +42,8 @@ namespace OpenRa.FileFormats
public readonly ushort Width;
public readonly ushort Height;
public Size Size { get { return new Size(Width, Height); } }
private readonly List<ImageHeader> headers = new List<ImageHeader>();
int recurseDepth = 0;

View File

@@ -16,6 +16,7 @@ namespace OpenRa.FileFormats
readonly byte[] index;
readonly List<Bitmap> TileBitmaps = new List<Bitmap>();
public readonly List<byte[]> TileBitmapBytes = new List<byte[]>();
public Terrain( Stream stream, Palette pal )
{
@@ -44,15 +45,19 @@ namespace OpenRa.FileFormats
for( int i = 0 ; i < index.Length ; i++ )
{
if( index[ i ] != 255 )
if (index[i] != 255)
{
byte[] tileData = new byte[ 24 * 24 ];
stream.Position = ImgStart + index[ i ] * 24 * 24;
stream.Read( tileData, 0, 24 * 24 );
TileBitmaps.Add( BitmapBuilder.FromBytes( tileData, 24, 24, pal ) );
byte[] tileData = new byte[24 * 24];
stream.Position = ImgStart + index[i] * 24 * 24;
stream.Read(tileData, 0, 24 * 24);
TileBitmaps.Add(BitmapBuilder.FromBytes(tileData, new Size(24, 24), pal));
TileBitmapBytes.Add(tileData);
}
else
TileBitmaps.Add( null );
{
TileBitmaps.Add(null);
TileBitmapBytes.Add(null);
}
}
}