git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1060 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
chrisf
2007-06-22 09:19:39 +00:00
parent 0710d99265
commit 73c4ee6817
6 changed files with 39 additions and 2 deletions

View File

@@ -40,6 +40,7 @@
<ItemGroup>
<Compile Include="Format40.cs" />
<Compile Include="Format80.cs" />
<Compile Include="Palette.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShpReader.cs" />
</ItemGroup>

33
ImageDecode/Palette.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
namespace ImageDecode
{
public class Palette
{
List<Color> colors = new List<Color>();
public Color GetColor(int index)
{
return colors[index];
}
public Palette(Stream s)
{
using (BinaryReader reader = new BinaryReader(s))
{
for (int i = 0; i < 256; i++)
{
byte r = (byte)(reader.ReadByte() << 2);
byte g = (byte)(reader.ReadByte() << 2);
byte b = (byte)(reader.ReadByte() << 2);
colors.Add(Color.FromArgb(r, g, b));
}
}
}
}
}

View File

@@ -20,6 +20,7 @@ namespace ShpViewer
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "SHP Files|*.shp";
ofd.RestoreDirectory = true;
if( ofd.ShowDialog() == DialogResult.OK )
Application.Run( new ShpViewForm( ofd.FileName ) );
}

View File

@@ -23,10 +23,12 @@ namespace ShpViewer
{
byte[] imageBytes = h.Image;
Bitmap bitmap = new System.Drawing.Bitmap( shpReader.Width, shpReader.Height );
Palette pal = new Palette(File.OpenRead("../../../temperat.pal"));
Bitmap bitmap = new Bitmap( shpReader.Width, shpReader.Height );
for( int x = 0 ; x < shpReader.Width ; x++ )
for( int y = 0 ; y < shpReader.Height ; y++ )
bitmap.SetPixel( x, y, Color.FromArgb( imageBytes[ x + shpReader.Width * y ], 0, 0 ) );
bitmap.SetPixel( x, y, pal.GetColor(imageBytes[ x + shpReader.Width * y ]) );
bitmaps.Add( bitmap );
}

BIN
temperat.pal Normal file

Binary file not shown.

BIN
tenticon.shp Normal file

Binary file not shown.