diff --git a/ImageDecode/ImageDecode.csproj b/ImageDecode/ImageDecode.csproj index 4d0cf29896..cd461a8b92 100644 --- a/ImageDecode/ImageDecode.csproj +++ b/ImageDecode/ImageDecode.csproj @@ -40,6 +40,7 @@ + diff --git a/ImageDecode/Palette.cs b/ImageDecode/Palette.cs new file mode 100644 index 0000000000..5aa9f31fe9 --- /dev/null +++ b/ImageDecode/Palette.cs @@ -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 colors = new List(); + + 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)); + } + } + } + } +} diff --git a/ShpViewer/Program.cs b/ShpViewer/Program.cs index f18dc2c1f9..4fdb22aedd 100644 --- a/ShpViewer/Program.cs +++ b/ShpViewer/Program.cs @@ -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 ) ); } diff --git a/ShpViewer/ShpViewForm.cs b/ShpViewer/ShpViewForm.cs index 8c52754d70..2564d31beb 100644 --- a/ShpViewer/ShpViewForm.cs +++ b/ShpViewer/ShpViewForm.cs @@ -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 ); } diff --git a/temperat.pal b/temperat.pal new file mode 100644 index 0000000000..bb63fcdd50 Binary files /dev/null and b/temperat.pal differ diff --git a/tenticon.shp b/tenticon.shp new file mode 100644 index 0000000000..1285ce644c Binary files /dev/null and b/tenticon.shp differ