<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sprite sheet | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/sprite-sheet/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Thu, 20 Aug 2020 18:36:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>sprite sheet | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>How to create an Alphabet bitmap in CSharp</title>
		<link>https://learncgames.com/how-to-create-an-alphabet-bitmap-in-csharp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-an-alphabet-bitmap-in-csharp</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 21 Aug 2020 23:00:36 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[sprite sheet]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1220</guid>

					<description><![CDATA[<p>Here&#8217;s another short utility. I have been looking for a decent alphabet to look in my next game (called HogWash) . As before, I want to create a sprite sheet with letters. But every alphabet set that I found had issues with kerning. I kid you not, usually but not always with M, W, or [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-create-an-alphabet-bitmap-in-csharp/">How to create an Alphabet bitmap in CSharp</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignleft size-medium wp-image-1222" src="https://learncgames.com/wp-content/uploads/2020/08/hwletters-300x225.png" alt="Letters generated by the program" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2020/08/hwletters-300x225.png 300w, https://learncgames.com/wp-content/uploads/2020/08/hwletters-768x576.png 768w, https://learncgames.com/wp-content/uploads/2020/08/hwletters.png 800w" sizes="(max-width: 300px) 100vw, 300px" />Here&#8217;s another short utility. I have been looking for a decent alphabet to look in my next game (<em>called HogWash</em>) . As before, I want to create a sprite sheet with letters. But every alphabet set that I found had issues with kerning. I kid you not, usually but not always with M, W, or even Q.</p>
<p>Even when I put together a sprite sheet manually, the editor didn&#8217;t quite get it right and letters didn&#8217;t quite fit the grid. So to simplify it, here;&#8217;s a 50 line C# program that takes the letters you supply in a string, combined with a font (Liberation Mono- from Red Hat) and a brush (black solid). It does a double loop that I exit with a goto (<em>shock horror!)</em> when it reaches the a terminating * in the string I supplied.</p>
<p>That is the graphic file above that the program below generated. As you can see the letters are far enough apart so no overlapping. Just put in <em>your path</em> where I have for the source and dest consts. You can use this technique for building sprite sheet.</p>
<pre><code class="language-csharp" data-line="">// Author D. Bolton Learncgames.com You are free to use and copy this program as you wish but please leave this line in.
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace buildfont
{
    class Program
    {
        const int LetterWidth = 100;
        const int LetterHeight = 120;
        const string source = &quot;Your path&quot;
        const string dest = @&quot;YourPath\letters.png&quot;;

        static Bitmap allLetters = new Bitmap(LetterWidth * 8,LetterHeight * 5);

        static void Main(string[] args)
        {
            BuildOneImage();
        }

        private static void BuildOneImage()
        {
            var font = new Font(&quot;Liberation Mono&quot;,95);
            var brush = new SolidBrush(Color.Black);
            var str = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ*&quot;;
            Console.WriteLine(&quot;Creating letters.png&quot;);
            var aty = 0.0f;
            using (Graphics g = Graphics.FromImage(allLetters))
            {
                var strindex = 0;
                for (var y = 0; y &lt; 5; y++)
                {
                    var atx = 0.0f;
                    for (int x = 0; x &lt; 6; x++)
                    {
                        string aLetter = str[strindex++].ToString();
                        if (aLetter == &quot;*&quot;) goto Done;
                        g.DrawString(aLetter, font, brush, atx, aty);
                        atx += LetterWidth;
                    }
                    aty += LetterHeight;
                }
            }
            Done:
            allLetters.Save(dest, ImageFormat.Png);
        }
    }
}</code></pre>The post <a href="https://learncgames.com/how-to-create-an-alphabet-bitmap-in-csharp/">How to create an Alphabet bitmap in CSharp</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1220</post-id>	</item>
	</channel>
</rss>
