-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b3c8283
Showing
5 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.31101.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldTibiaExtractor", "OldTibiaExtractor\OldTibiaExtractor.csproj", "{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{BD4961EC-4B96-42E4-BC15-E15F18B9B70F}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>OldTibiaExtractor</RootNamespace> | ||
<AssemblyName>OldTibiaExtractor</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace OldTibiaExtractor | ||
{ | ||
class Program | ||
{ | ||
static System.Drawing.Imaging.ColorPalette colorPalette; | ||
|
||
static void ExtractPIC(string filename) | ||
{ | ||
using (System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead(filename))) { | ||
ushort width = (ushort)(reader.ReadUInt16() + 2); | ||
ushort height = (ushort)(reader.ReadUInt16() + 2); | ||
Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); | ||
bmp.Palette = colorPalette; | ||
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); | ||
byte[] byteArray = new byte[width * height]; | ||
|
||
for (int x = 1; x < (height - 1); x++) { | ||
for (int y = 1; y < (width - 1); y++) { | ||
byteArray[(width * x) + y] = reader.ReadByte(); | ||
} | ||
} | ||
|
||
System.Runtime.InteropServices.Marshal.Copy(byteArray, 0, bmpData.Scan0, width * height); | ||
bmp.UnlockBits(bmpData); | ||
bmp.Save(filename.Substring(0, filename.IndexOf(".")) + ".bmp"); | ||
bmp.Dispose(); | ||
} | ||
} | ||
|
||
static void ExtractSPR(string filename) | ||
{ | ||
using (System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead("TIBIA.SPR"))) { | ||
ushort count = reader.ReadUInt16(); | ||
reader.BaseStream.Seek(6, System.IO.SeekOrigin.Current); | ||
|
||
for (int a = 1; a < count; a++) { | ||
Bitmap bmp = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); | ||
bmp.Palette = colorPalette; | ||
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, 32, 32), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); | ||
byte[] byteArray = new byte[1024]; | ||
|
||
for (int b = 0; b < 1024; b++) { | ||
byteArray[b] = 0xFF; | ||
} | ||
|
||
long size = reader.ReadUInt16(); | ||
size += reader.BaseStream.Position - 1; | ||
int i = 0; | ||
|
||
while (reader.BaseStream.Position <= size) { | ||
if (reader.BaseStream.Position >= reader.BaseStream.Length) { | ||
break; | ||
} | ||
|
||
ushort tPixels = reader.ReadUInt16(); | ||
i += tPixels; | ||
|
||
if (reader.BaseStream.Position > size) { | ||
break; | ||
} | ||
|
||
byte cPixels = reader.ReadByte(); | ||
|
||
for (int c = 0; c < cPixels; c++) { | ||
byte color = reader.ReadByte(); | ||
byteArray[i] = color; | ||
i++; | ||
} | ||
} | ||
|
||
System.Runtime.InteropServices.Marshal.Copy(byteArray, 0, bmpData.Scan0, 1024); | ||
bmp.UnlockBits(bmpData); | ||
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); | ||
|
||
if (!System.IO.Directory.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), "Sprites\\"))) { | ||
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), "Sprites\\")); | ||
} | ||
|
||
bmp.Save(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), "Sprites\\" + a.ToString() + ".bmp")); | ||
bmp.Dispose(); | ||
} | ||
} | ||
} | ||
|
||
static void SetPalette(string filename) | ||
{ | ||
using (System.IO.BinaryReader palette = new System.IO.BinaryReader(System.IO.File.OpenRead(filename))) { | ||
for (int p = 0; p < 256; p++) { | ||
colorPalette.Entries[p] = Color.FromArgb(palette.ReadByte(), palette.ReadByte(), palette.ReadByte()); | ||
} | ||
} | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
if (!System.IO.File.Exists("Palette.dat")) { | ||
Console.WriteLine("Palette.dat could not be found. Place Palette.dat in the same folder as OldTibiaExtractor and try again."); | ||
Console.ReadKey(); | ||
return; | ||
} | ||
|
||
Bitmap bmp = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); | ||
colorPalette = bmp.Palette; | ||
SetPalette("Palette.dat"); | ||
|
||
foreach (string filename in System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))) { | ||
if (filename.Contains(".PIC")) { | ||
ExtractPIC(filename); | ||
} | ||
|
||
if (filename.Contains(".SPR")) { | ||
ExtractSPR(filename); | ||
} | ||
} | ||
|
||
bmp.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("OldTibiaExtractor")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("OldTibiaExtractor")] | ||
[assembly: AssemblyCopyright("Copyright © 2015")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("07c9bce8-2044-4bb1-be85-dca065f39a92")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |