update Demo project

mainly just removed serialization demo code since that has been removed
from the main library due to the PCL change.
This commit is contained in:
Gered 2013-08-11 10:29:30 -04:00
parent 8babb25399
commit 4598b08c08
3 changed files with 17 additions and 47 deletions

View file

@ -23,8 +23,6 @@
using System;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace TrueTypeSharp.Demo
{
@ -47,7 +45,7 @@ namespace TrueTypeSharp.Demo
static void Main(string[] args)
{
var font = new TrueTypeFont(@"Anonymous/Anonymous Pro.ttf");
var font = new TrueTypeFont(new FileStream(@"Anonymous/Anonymous Pro.ttf", FileMode.Open));
// Render some characters...
for (char ch = 'A'; ch <= 'Z'; ch++)
@ -65,38 +63,8 @@ namespace TrueTypeSharp.Demo
var bitmap = font.BakeFontBitmap(pixelHeight, out characters, true);
SaveBitmap(bitmap.Buffer, 0, 0, bitmap.Width, bitmap.Height, bitmap.Width, "BakeResult1.png");
// Now, let's give serialization a go.
using (var file = File.OpenWrite("BakeResult2.temp"))
{
var bitmapSaver = new BinaryFormatter();
bitmapSaver.Serialize(file, bitmap);
bitmapSaver.Serialize(file, characters);
int ascent, descent, lineGap;
float scale = font.GetScaleForPixelHeight(pixelHeight);
font.GetFontVMetrics(out ascent, out descent, out lineGap);
bitmapSaver.Serialize(file, (float)ascent * scale);
bitmapSaver.Serialize(file, (float)descent * scale);
bitmapSaver.Serialize(file, (float)lineGap * scale);
}
using (var file = File.OpenRead("BakeResult2.temp"))
{
var bitmapLoader = new BinaryFormatter();
var bitmapAgain = (FontBitmap)bitmapLoader.Deserialize(file);
var charactersAgain = (BakedCharCollection)bitmapLoader.Deserialize(file);
SaveBitmap(bitmapAgain.Buffer, 0, 0, bitmapAgain.Width, bitmapAgain.Height, bitmap.Width, "BakeResult2.png");
for (char ch = 'A'; ch <= 'Z'; ch++)
{
BakedChar bakedChar = charactersAgain[ch];
if (bakedChar.IsEmpty) { continue; }
SaveBitmap(bitmapAgain.Buffer,
bakedChar.X0, bakedChar.Y0, bakedChar.X1, bakedChar.Y1,
bitmapAgain.Stride, "SmallChar-" + ch.ToString() + ".png");
}
}
// TODO: implement serialization equivalent that is compatible with a Portable Class Library ...
}
}
}

View file

@ -10,7 +10,6 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TrueTypeSharp.Demo</RootNamespace>
<AssemblyName>TrueTypeSharp.Demo</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
@ -58,12 +57,6 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TrueTypeSharp\TrueTypeSharp.csproj">
<Project>{B722113F-1252-4BE1-9D43-6BC82B3E37D1}</Project>
<Name>TrueTypeSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
@ -89,4 +82,10 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<ProjectReference Include="..\TrueTypeSharp\TrueTypeSharp.csproj">
<Project>{1651CC69-D1D5-4770-9C93-45CB91579130}</Project>
<Name>TrueTypeSharp</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

@ -1,25 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp", "TrueTypeSharp\TrueTypeSharp.csproj", "{B722113F-1252-4BE1-9D43-6BC82B3E37D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp.Demo", "TrueTypeSharp.Demo\TrueTypeSharp.Demo.csproj", "{B067AB58-D823-4A46-97E1-43BC75F7FF35}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp", "TrueTypeSharp\TrueTypeSharp.csproj", "{1651CC69-D1D5-4770-9C93-45CB91579130}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Release|Any CPU.Build.0 = Release|Any CPU
{1651CC69-D1D5-4770-9C93-45CB91579130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1651CC69-D1D5-4770-9C93-45CB91579130}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1651CC69-D1D5-4770-9C93-45CB91579130}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1651CC69-D1D5-4770-9C93-45CB91579130}.Release|Any CPU.Build.0 = Release|Any CPU
{B067AB58-D823-4A46-97E1-43BC75F7FF35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B067AB58-D823-4A46-97E1-43BC75F7FF35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B067AB58-D823-4A46-97E1-43BC75F7FF35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B067AB58-D823-4A46-97E1-43BC75F7FF35}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = TrueTypeSharp.Demo\TrueTypeSharp.Demo.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection