git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1060 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -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
33
ImageDecode/Palette.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
@@ -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
BIN
temperat.pal
Normal file
Binary file not shown.
BIN
tenticon.shp
Normal file
BIN
tenticon.shp
Normal file
Binary file not shown.
Reference in New Issue
Block a user