79 using System.Collections.Generic;
81 using System.Drawing.Imaging;
83 namespace SiliconStudio.Paradox.Assets.SpriteFont.Compiler
93 internal class BitmapImporter : IFontImporter
98 public float LineSpacing {
get;
private set; }
100 public float BaseLine {
get {
return 0; } }
109 bitmap =
new Bitmap(options.
Source);
113 throw new FontNotFoundException(options.
Source);
117 bitmap = BitmapUtils.ChangePixelFormat(bitmap, PixelFormat.Format32bppArgb);
120 int characterIndex = 0;
121 char currentCharacter =
'\0';
124 var glyphList =
new List<Glyph>();
129 foreach (
Rectangle rectangle
in FindGlyphs(bitmap))
131 if (characterIndex < characters.Count)
132 currentCharacter = characters[characterIndex++];
136 glyphList.Add(
new Glyph(currentCharacter, bitmap, rectangle) { XAdvance = rectangle.Width });
138 LineSpacing = Math.Max(LineSpacing, rectangle.Height);
142 if (BitmapUtils.IsAlphaEntirely(255, bitmap))
144 BitmapUtils.ConvertGreyToAlpha(bitmap,
new Rectangle(0,0,bitmap.Width, bitmap.Height));
154 for (
int y = 1;
y < bitmap.Height;
y++)
156 for (
int x = 1; x < bitmap.Width; x++)
159 if (!IsMarkerColor(bitmapData[x,
y]) &&
160 IsMarkerColor(bitmapData[x - 1,
y]) &&
161 IsMarkerColor(bitmapData[x,
y - 1]))
166 while ((x + w < bitmap.Width) && !IsMarkerColor(bitmapData[x + w,
y]))
171 while ((
y + h < bitmap.Height) && !IsMarkerColor(bitmapData[x,
y + h]))
185 static bool IsMarkerColor(
Color color)
187 return color.ToArgb() ==
Color.Magenta.ToArgb();
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
SiliconStudio.Core.Mathematics.Color Color
UFile Source
Gets or sets the source file containing the font data if required.
System.Windows.Shapes.Rectangle Rectangle