<?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>utility | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/utility/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>Sun, 23 Mar 2025 14:39:41 +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>utility | 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>Interesting bug with controllermap</title>
		<link>https://learncgames.com/interesting-bug-with-controllermap/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=interesting-bug-with-controllermap</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 23 Mar 2025 14:35:44 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[utility]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3356</guid>

					<description><![CDATA[<p>So I&#8217;ve been playing with a Rust program that uses the config string generated by controllermap. It shows all the keys and the text of a particular button turns green when you press it and it shows PRESSED/RELEASED. But it got A and B buttons mixed up and also X and Y. I&#8217;d press A, [&#8230;]</p>
The post <a href="https://learncgames.com/interesting-bug-with-controllermap/">Interesting bug with controllermap</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 wp-image-3357" src="https://learncgames.com/wp-content/uploads/2025/03/test.png" alt="Running a Rust program to show gamepad controls" width="500" height="390" srcset="https://learncgames.com/wp-content/uploads/2025/03/test.png 801w, https://learncgames.com/wp-content/uploads/2025/03/test-300x234.png 300w, https://learncgames.com/wp-content/uploads/2025/03/test-768x598.png 768w" sizes="(max-width: 500px) 100vw, 500px" /></p>
<p>So I&#8217;ve been playing with a Rust program that uses the config string generated by <a title="Link to blog post about controllermap" href="https://learncgames.com/new-tutorial-posted-how-to-build-controllermap-in-linux/" target="_blank" rel="noopener">controllermap</a>. It shows all the keys and the text of a particular button turns green when you press it and it shows PRESSED/RELEASED.</p>
<p>But it got A and B buttons mixed up and also X and Y. I&#8217;d press A, it highlighted B etc.</p>
<p>I checked my code, it wasn&#8217;t there. I ran controllermap again and it generated a similar config string.</p>
<p>I then went back to the Pi version of Asteroids, put it on a Pi, started debugging it, pressed the fire button and it hit the line of code for the A button. D&#8217;oh.</p>
<p>The only conclusion I can come up with is that controllermap gets it wrong for my gamepad. I had somehow missed it when I added gamepad control for the Asteroid Pi.</p>
<p>It&#8217;s quite easy to fix.  This is what the full text in gamepad.txt look like.</p>
<pre>030000001008000001e5000010010000,usb gamepad,platform:Linux,crc:417e,<strong>a:b2,b:b1,x:b3,y:b0</strong>,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,</pre>
<p>but we&#8217;re only interesed in the button mappings for a,b, x and y which are in bold.</p>
<p>a:b2,b:b1,x:b3,y:b0,</p>
<p>Just swap the a b mappings and the x and y so it looks like</p>
<pre>a:b1,b:b2,x:b0,y,b3</pre>
<p>Then save the file and it now works correctly.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/interesting-bug-with-controllermap/">Interesting bug with controllermap</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">3356</post-id>	</item>
		<item>
		<title>How to create a Controller Map on Raspberry Pi</title>
		<link>https://learncgames.com/how-to-create-a-controller-map-on-raspberry-pi/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-a-controller-map-on-raspberry-pi</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 27 Dec 2022 00:00:58 +0000</pubDate>
				<category><![CDATA[Game]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[gamepqd]]></category>
		<category><![CDATA[mapping]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3159</guid>

					<description><![CDATA[<p>Updated 20/03/2025 I&#8217;ve since discovered since I got a Raspi 5 that the install-tools are no longer built and included when you install SDL2 which means controllermap used in this article isn&#8217;t easily available. However the source code is available (and all the tests) and only needs a bit of tweaking to build it on [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-create-a-controller-map-on-raspberry-pi/">How to create a Controller Map on Raspberry Pi</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<h2><img decoding="async" class="alignleft size-full wp-image-3168" src="https://learncgames.com/wp-content/uploads/2022/12/gamecontrollermap.png" alt="Game Controller map screenshot" width="618" height="399" srcset="https://learncgames.com/wp-content/uploads/2022/12/gamecontrollermap.png 618w, https://learncgames.com/wp-content/uploads/2022/12/gamecontrollermap-300x194.png 300w" sizes="(max-width: 618px) 100vw, 618px" />Updated 20/03/2025</h2>
<p>I&#8217;ve since discovered since I got a Raspi 5 that the install-tools are no longer built and included when you install SDL2 which means controllermap used in this article isn&#8217;t easily available.</p>
<p>However the source code is available (and all the tests) and only needs a bit of tweaking to build it on a Raspberry Pi.</p>
<p>I will add a tutorial to build it and will link to it once done.</p>
<p>&#8212; Rest of article &#8212;</p>
<p>I&#8217;ve been working on my 2nd eBook and adding a GamePad is a thing I need to explain. You can see them in earlier blog posts:</p>
<ol>
<li><a title="Link to blog post fun with gamepads" href="https://learncgames.com/fun-with-game-pads/" target="_blank" rel="noopener">Fun with gamepads</a>.</li>
<li><a title="Link to More on Raspberry Pi Gamepads" href="https://learncgames.com/more-on-raspberry-pi-gamepad/" target="_blank" rel="noopener">More on Raspberry Pi Gamepads</a>.</li>
</ol>
<p>But I want readers of the book to be able to generate their own controller maps. I cannot assume that everyone has access to Windows.</p>
<p>What I didn&#8217;t know back then is that SDL comes with a game controller map generator application called (subtle this!) <strong>controllermap </strong>that you can run on your Pi or Linux computer.</p>
<p>&nbsp;</p>
<p>I had to use the File Manager <em>Find file</em> facility to locate it. It&#8217;s in the installed-tests folder for SDL2 or more precisely <strong>/usr/lib/aarch64-linux-gnu/installed-tests/SDL2 </strong>on my Raspberry Pi running 64-bit Raspberry Pi OS.</p>
<p>On my VM Ubuntu I found it in <strong>/usr/lib/x86-64-linux-gnu/installed-tests/SDL2</strong></p>
<p>I did a bit of experimenting with a clean Raspberry Pi OS setup and then I installed <strong>libsdl2-dev</strong> and saw the <strong>installed-tests/SDL2</strong> folder installed, so that&#8217;s what you need. So install the dev files as per <a title="Link to Tutorial on installing SDL on Linux" href="https://learncgames.com/new-tutorial-on-installing-sdl-on-linux/" target="_blank" rel="noopener">New tutorial on installing SDL on Linux.</a></p>
<p>Plug in a gamepad and on your Pi, cd into that folder (<em>the Pi one not the Ubuntu one!</em>)  and in a terminal run <strong>./controllermap</strong></p>
<p><img decoding="async" class="alignleft wp-image-566 size-medium" src="https://learncgames.com/wp-content/uploads/2020/04/usb-joypad-300x131.png" alt="USB Joypad" width="300" height="131" srcset="https://learncgames.com/wp-content/uploads/2020/04/usb-joypad-300x131.png 300w, https://learncgames.com/wp-content/uploads/2020/04/usb-joypad.png 454w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>It will open with your B button highlighted. Press your B button. In the picture above it&#8217;s the circle on the right hand side that is the lowest of the four or the yellow button in this picture of my controller.</p>
<p>It will then go through every possible button.  Just press the corresponding button or space key if you haven&#8217;t got that. Compared to the main picture, mine lacks the two bottom joysticks, the buttons between the Stop and Start buttons and the two trigger buttons at the top. For each of those just press the space bar.  Eventually it will loop back to the B button. Just press it and it will finish and output the gamepad control map.</p>
<p>It outputs two copies of this. You can send one to a text file in your home folder by doing</p>
<p><strong>./controllermap &gt;~/gamepad.txt </strong></p>
<p>but you will have to press all the buttons etc. again. This is what my Pi gave.</p>
<p>030000001008000001e5000010010000,usb gamepad,platform:Linux,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,</p>
<p>And that is what you use in SDL2 code.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/how-to-create-a-controller-map-on-raspberry-pi/">How to create a Controller Map on Raspberry Pi</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">3159</post-id>	</item>
		<item>
		<title>A very useful Windows Utility in C</title>
		<link>https://learncgames.com/a-very-useful-windows-utility-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-very-useful-windows-utility-in-c</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 13 Dec 2022 00:00:07 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[Windows 11]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3135</guid>

					<description><![CDATA[<p>If you use Windows 11 you&#8217;ll be aware of one or two issues with it; the file explorer popup menu needs a second click to take you to the Windows 10 menu with Copy, cut paste etc. So I was pleased to discover explorer patcher which is a utility written in C that lets you get [&#8230;]</p>
The post <a href="https://learncgames.com/a-very-useful-windows-utility-in-c/">A very useful Windows Utility in C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:40,&quot;href&quot;:&quot;https:\/\/github.com\/valinet\/ExplorerPatcher&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205093017\/https:\/\/github.com\/valinet\/ExplorerPatcher&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:14:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 13:54:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 05:50:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 07:18:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-01 04:10:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-04 18:50:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 05:20:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 08:07:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 04:48:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 01:58:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 11:07:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 18:21:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 22:53:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 03:34:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 15:12:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 17:47:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 11:50:26&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 11:50:26&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3137" src="https://learncgames.com/wp-content/uploads/2022/12/explorerpatcher.png" alt="ExplorerPatcher menu" width="622" height="547" srcset="https://learncgames.com/wp-content/uploads/2022/12/explorerpatcher.png 622w, https://learncgames.com/wp-content/uploads/2022/12/explorerpatcher-300x264.png 300w" sizes="auto, (max-width: 622px) 100vw, 622px" />If you use Windows 11 you&#8217;ll be aware of one or two issues with it; the file explorer popup menu needs a second click to take you to the Windows 10 menu with Copy, cut paste etc.</p>
<p>So I was pleased to discover <a title="Link to ExplorerPatcher on GitHub" href="https://github.com/valinet/ExplorerPatcher" target="_blank" rel="noopener">explorer patcher</a> which is a utility written in C that lets you get the Windows 10 right-click menu back as well as changing the File explorer right-click popup menu and a lot of other stuff.</p>
<p>It&#8217;s on GitHub and the authors are happy for you to look at the source code and submit improvements of your own.</p>
<p>If you want to see how to make changes to Windows etc in C, this is a great example.</p>
<p>Added to the <a title="Link to C Code Links" href="https://learncgames.com/c-code-links/" target="_blank" rel="noopener">C Code Links</a> page.</p>
<p>PS. I use this and have found that after a Windows update, the right-click menu gets reset to the Windows 11. However just opening the explorer patcher settings and unticking then ticking the option for <em>Disable the Windows 11 context menu</em> on the <strong>File Explorer</strong> menu fixes it.</p>The post <a href="https://learncgames.com/a-very-useful-windows-utility-in-c/">A very useful Windows Utility in C</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">3135</post-id>	</item>
		<item>
		<title>Mle &#8211; a small text editor in under 10,000 lines of code</title>
		<link>https://learncgames.com/mle-a-small-text-editor-in-under-10000-lines-of-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mle-a-small-text-editor-in-under-10000-lines-of-code</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 01 Oct 2022 23:00:30 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Text editor]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3080</guid>

					<description><![CDATA[<p>If you&#8217;re into C, one of the most interesting applications you can write is a text editor. It demands ability to use pointers for storing the text efficiently and command handling and doing things like searching, handling Unicode. It can be equally instructive reading code someone else has written and this case Mle, is a [&#8230;]</p>
The post <a href="https://learncgames.com/mle-a-small-text-editor-in-under-10000-lines-of-code/">Mle – a small text editor in under 10,000 lines of code</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:49,&quot;href&quot;:&quot;https:\/\/github.com\/adsr\/mle&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260129090516\/https:\/\/github.com\/adsr\/mle&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:25:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 00:17:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-14 11:09:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 13:54:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 05:50:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 12:29:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 08:04:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 05:20:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 08:08:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 04:48:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 10:35:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 10:36:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 10:59:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 11:19:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 13:24:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-12 22:21:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 05:48:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-20 09:51:17&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 09:51:17&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3081" src="https://learncgames.com/wp-content/uploads/2022/10/mie-text-editor.png" alt="Mie text editor" width="450" height="315" srcset="https://learncgames.com/wp-content/uploads/2022/10/mie-text-editor.png 450w, https://learncgames.com/wp-content/uploads/2022/10/mie-text-editor-300x210.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" />If you&#8217;re into C, one of the most interesting applications you can write is a text editor. It demands ability to use pointers for storing the text efficiently and command handling and doing things like searching, handling Unicode.</p>
<p>It can be equally instructive reading code someone else has written and this case <a title="Link to Mie text editor on GitHub" href="https://github.com/adsr/mle" target="_blank" rel="nofollow noopener">Mle</a>, is a text editor in less than 10,000 lines of C. It&#8217;s also cross-platform apparently, though you&#8217;ll have to build it on the relevant platform.</p>
<p>It uses three other open source libraries, linked at the foot of the main page. They are uthash, termbox2 and PCRE2.</p>The post <a href="https://learncgames.com/mle-a-small-text-editor-in-under-10000-lines-of-code/">Mle – a small text editor in under 10,000 lines of code</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">3080</post-id>	</item>
		<item>
		<title>Everything and fsearch</title>
		<link>https://learncgames.com/everything-and-fsearch/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=everything-and-fsearch</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 31 Jul 2022 13:30:08 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[search]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3070</guid>

					<description><![CDATA[<p>I&#8217;m currently operating on a Linux laptop as the M2 SSD on my new desktop PC decided to stop working the other day.  But I thought I&#8217;d mention a couple of utilities that I&#8217;ve recently started using. My new PC, just three months old when working has a 1TB M2 SSD with Windows on it. [&#8230;]</p>
The post <a href="https://learncgames.com/everything-and-fsearch/">Everything and fsearch</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:50,&quot;href&quot;:&quot;https:\/\/www.voidtools.com\/support\/everything&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260204030430\/https:\/\/www.voidtools.com\/support\/everything\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:26:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 12:14:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 10:48:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-18 22:09:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 03:45:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 01:19:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 00:00:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 20:14:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 00:02:02&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 23:18:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 03:34:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 00:45:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 23:44:21&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-18 23:44:21&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:51,&quot;href&quot;:&quot;https:\/\/github.com\/cboxdoerfer\/fsearch&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260202091529\/https:\/\/github.com\/cboxdoerfer\/fsearch&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:26:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 12:14:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 00:00:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 20:14:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 00:02:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 23:18:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 03:34:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 00:45:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 22:48:03&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 22:48:03&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft wp-image-3071 size-medium" src="https://learncgames.com/wp-content/uploads/2022/07/Everything.Search.Window-300x256.png" alt="Everything File Search" width="300" height="256" srcset="https://learncgames.com/wp-content/uploads/2022/07/Everything.Search.Window-300x256.png 300w, https://learncgames.com/wp-content/uploads/2022/07/Everything.Search.Window.png 660w" sizes="auto, (max-width: 300px) 100vw, 300px" />I&#8217;m currently operating on a Linux laptop as the M2 SSD on my new desktop PC decided to stop working the other day.  But I thought I&#8217;d mention a couple of utilities that I&#8217;ve recently started using.</p>
<p>My new PC, just three months old when working has a 1TB M2 SSD with Windows on it. Most software is installed here. All the data, backups, everything else is stored on a 10 TB Hard disk. This is my 10th PC since 1989 so it has the name PC10. Yes, original I know.</p>
<p>I have been copying everything I&#8217;ve created and written since 1989 and like a snowball rolling down a hill it has grown. When I finished copying everything from my old PC; a process that took a large chunk of four days, I&#8217;d used 2.3 TB out of the 10 TB hard disk.   I just copied across the Gigabit network connection and it maxxed out at 113 MB/S. That&#8217;s even with anti-virus running. Of course Windows has an overhead so sometimes the transfer speed drops down to KB/S for small files. I worked it out that over the 48 hours (4 days- 12 hours a day), it copied at 13 MB/S average.</p>
<p>In future it might make sense to zip up folders with small files in them. In the meantime I need to do a bit of pruning of files, removing duplicates etc.</p>
<h2>Everything</h2>
<p>I&#8217;d been looking for a utility to let me find files quickly and somebody had suggested <a title="Link to Everything File Search" href="https://www.voidtools.com/support/everything/" target="_blank" rel="noopener">Everything</a>. It&#8217;s brilliant. It tells me that I have just over 4 million files. I can filter on document types, images, music files or just search on matching names. And it is very very fast. If you want to find the massive file that&#8217;s eating up disk space or duplicates, it does it. But it&#8217;s only for Windows. <em>Lacking a Windows system at the mo, I&#8217;ve just borrowed the image from the Everything home page.</em></p>
<h2>Fsearch</h2>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3072" src="https://learncgames.com/wp-content/uploads/2022/07/FSearch-300x211.png" alt="FSearch window" width="300" height="211" srcset="https://learncgames.com/wp-content/uploads/2022/07/FSearch-300x211.png 300w, https://learncgames.com/wp-content/uploads/2022/07/FSearch-768x541.png 768w, https://learncgames.com/wp-content/uploads/2022/07/FSearch.png 857w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>Developer Christian Boxdörfer also liked Everything and decided to create a Unix clone of it which is <a title="Link to fsearch on GitHub" href="https://github.com/cboxdoerfer/fsearch" target="_blank" rel="noopener">FSearch</a>. And it&#8217;s written in C. That&#8217;s it on the left.</p>
<p>I set it to find all C files and sorted by size.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/everything-and-fsearch/">Everything and fsearch</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">3070</post-id>	</item>
		<item>
		<title>A mini-project- SDL toolkit</title>
		<link>https://learncgames.com/a-mini-project-sdl-toolkit/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-mini-project-sdl-toolkit</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 13 Feb 2021 00:00:52 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[SDL toolkit]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2660</guid>

					<description><![CDATA[<p>I&#8217;ve thought about doing this for a while. Build a small toolkit (a library) of helper routines for any program that uses the SDL2 library. That means it will have functions to do the following: Draw horizontal and vertical lines in a specified colour. Draw coloured rectangles both filled in and empty. Draw Circles of [&#8230;]</p>
The post <a href="https://learncgames.com/a-mini-project-sdl-toolkit/">A mini-project- SDL toolkit</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:180,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=5009497&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260128125116\/https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:31:20&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-21 20:24:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-28 11:59:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-03 22:29:16&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 20:10:15&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-17 20:43:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 10:35:24&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-01 00:01:58&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 23:18:52&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-09 08:58:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 17:44:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 05:48:51&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 06:34:11&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 06:34:11&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:181,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=5009497&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:31:38&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-15 10:48:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-21 20:24:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-28 11:59:56&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-03 22:29:16&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 20:10:12&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-17 04:48:24&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-21 04:46:32&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 10:35:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-01 04:21:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 23:18:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-09 08:58:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 17:44:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 05:48:50&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 06:34:12&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 06:34:12&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:19,&quot;href&quot;:&quot;https:\/\/libsdl.org&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260131222311\/https:\/\/www.libsdl.org\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 03:02:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 20:24:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-26 01:47:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 22:29:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 20:10:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-14 13:25:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 20:43:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 14:09:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 10:35:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 00:02:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 13:19:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 08:58:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-12 18:29:22&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-17 05:48:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-20 11:01:13&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 11:01:13&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2661" aria-describedby="caption-attachment-2661" style="width: 300px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-medium wp-image-2661" src="https://learncgames.com/wp-content/uploads/2021/02/color-5009497_640-300x200.jpg" alt="Coloured Rectangles" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2021/02/color-5009497_640-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2021/02/color-5009497_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2661" class="wp-caption-text">Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=5009497">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=5009497">Pixabay</a></figcaption></figure>
<p>I&#8217;ve thought about doing this for a while. Build a small toolkit (<em>a library)</em> of helper routines for any program that uses the <a title="Link to SDL website." href="https://libsdl.org/" target="_blank" rel="noopener">SDL2 library</a>. That means it will have functions to do the following:</p>
<ol>
<li>Draw horizontal and vertical lines in a specified colour.</li>
<li>Draw coloured rectangles both filled in and empty.</li>
<li>Draw Circles of specified radius and colour.</li>
<li>Draw hexagons in either orientation and of a specified size, hollow or filled.</li>
</ol>
<p>Plus any other things that occur to me. I&#8217;ll start on this shortly.</p>The post <a href="https://learncgames.com/a-mini-project-sdl-toolkit/">A mini-project- SDL toolkit</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">2660</post-id>	</item>
		<item>
		<title>SDL-TTF now on Raspberry Pi</title>
		<link>https://learncgames.com/sdl-ttf-now-on-raspberry-pi/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sdl-ttf-now-on-raspberry-pi</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 11 Dec 2020 00:00:43 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[ttf]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2037</guid>

					<description><![CDATA[<p>I eventually got the Windows SDL vs TTF comparison program converted to run on Raspberry-pi, after wrestling with VS Code&#8217;s Folder. Get it wrong and you can waste hours trying to get it to compile and link. I originally set the Folder (VS Code&#8217;s way of managing projects) to the pi/Projects folder (which contained both [&#8230;]</p>
The post <a href="https://learncgames.com/sdl-ttf-now-on-raspberry-pi/">SDL-TTF now on Raspberry Pi</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:14,&quot;href&quot;:&quot;https:\/\/github.com\/David-H-Bolton\/LearnCOnLinux&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250213114627\/https:\/\/github.com\/David-H-Bolton\/LearnCOnLinux&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 16:40:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 18:24:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 22:16:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-18 22:19:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 22:22:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 04:17:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 04:17:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 04:22:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 04:38:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 08:48:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 09:17:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 10:18:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 12:43:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 15:14:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 15:19:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-27 16:38:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 19:05:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 19:29:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 21:51:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 22:18:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 22:18:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 22:20:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 07:27:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 10:16:46&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 10:16:46&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-2038" src="https://learncgames.com/wp-content/uploads/2020/12/pi-screenshot.png" alt="Raspberry Pi screenshot" width="450" height="264" srcset="https://learncgames.com/wp-content/uploads/2020/12/pi-screenshot.png 450w, https://learncgames.com/wp-content/uploads/2020/12/pi-screenshot-300x176.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" />I eventually got the <a title="Link to comparison of SDL vs TTF fonts" href="https://learncgames.com/timing-of-sdl-vs-ttf-fonts/" target="_blank" rel="nofollow noopener noreferrer">Windows SDL vs TTF comparison</a> program converted to run on Raspberry-pi, after wrestling with VS Code&#8217;s Folder. Get it wrong and you can waste hours trying to get it to compile and link. I originally set the Folder (<em>VS Code&#8217;s way of managing projects</em>) to the <strong>pi/Projects</strong> folder (<em>which contained both asteroids and sdlttf folders</em>) but eventually I sussed it and set <strong>sdlttf</strong> as my Folder.  The login user is pi and so the pi folder is my home folder. I created the Projects folder under it.</p>
<p>This time the home brewed print routine (<strong>print</strong>) took 28x as long as the SDL_ttf compared to 14x on Windows. I used the same text.png and font.ttf files. The times are in the Window caption and read (<em>for those with poor contrast</em>) <strong>sdl: 35538.574 ttf: 1235.630.</strong> These times are the microsecond times to draw the strings 100x.</p>
<p>Changes were fairly minimal. I changed the <strong>fopen_s</strong> to <strong>fopen (</strong><em>used for error logging</em><strong>) </strong> and changed the paths to the two font files. The other change was in the timing which used the Linux versions of <strong>hr_time.h/.c</strong> and called the <strong>diff</strong>() function instead of <strong>GetElapsedTime</strong>().</p>
<p>I&#8217;ve zipped up the source file (<strong>sdlttf.c)</strong> plus timing files and JSON config files for VS Code in the sdlttf_pi.zip file and put it in the LearnConLinux repository on <a title="Link to LearnCOnLinux repository on GitHub" href="https://github.com/David-H-Bolton/LearnCOnLinux" target="_blank" rel="nofollow noopener noreferrer">GitHub</a>.</p>
<p>Note I created a projects folder then sdlttf under that. The paths in <strong>tasks.json</strong> reflect this. To build this you&#8217;ll need <strong>libsdl2-dev,libsdl2_image_dev</strong> and <strong>libsdl2-ttf-dev</strong> installed. I used clang version 7 (<em>the default installed on pi when you do <strong>sudo apt install clang</strong></em>) but I imagine gcc should also build it without any problems.</p>
<p>This matches my conclusions from running the virtually identical Windows version. The sdlttf way is way faster for prerendered strings than my print routine which just blits the characters out of the font bitmap one by one.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/sdl-ttf-now-on-raspberry-pi/">SDL-TTF now on Raspberry Pi</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">2037</post-id>	</item>
		<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 loading="lazy" 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="auto, (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>
		<item>
		<title>How to create a big image from a number of smaller ones</title>
		<link>https://learncgames.com/how-to-create-a-big-image-from-a-number-of-smaller-ones/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-a-big-image-from-a-number-of-smaller-ones</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 01 Aug 2020 23:00:59 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[graphics]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1095</guid>

					<description><![CDATA[<p>After the day before yesterday&#8217;s experiment showed that loading a single larger image on an Android phone is nearly three times faster than loading 52 smaller images, I decided to write a short utility program to read all the 52 individual card files and create one file with them laid out neatly in four rows [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-create-a-big-image-from-a-number-of-smaller-ones/">How to create a big image from a number of smaller ones</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:478,&quot;href&quot;:&quot;http:\/\/www.libpng.org\/pub\/png\/libpng.html&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260204064028\/https:\/\/www.libpng.org\/pub\/png\/libpng.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:15:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 02:14:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 09:31:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 23:50:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 17:26:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 04:48:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 10:35:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-29 14:35:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 10:29:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 22:53:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 02:01:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 23:03:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 22:48:01&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 22:48:01&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:601,&quot;href&quot;:&quot;http:\/\/acbl.mybigcommerce.com\/52-playing-cards&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251017150451\/https:\/\/acbl.mybigcommerce.com\/52-playing-cards\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 16:30:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-14 12:35:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 23:50:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 09:10:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 00:00:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 04:48:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 10:35:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 02:13:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 11:15:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 17:23:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-13 18:49:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 08:46:29&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-20 12:22:01&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 12:22:01&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-1097" src="https://learncgames.com/wp-content/uploads/2020/07/carddeck.png" alt="Card Deck" width="450" height="212" srcset="https://learncgames.com/wp-content/uploads/2020/07/carddeck.png 450w, https://learncgames.com/wp-content/uploads/2020/07/carddeck-300x141.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" />After the day before yesterday&#8217;s experiment showed that loading a single larger image on an Android phone is <em>nearly three times faster</em> than loading 52 smaller images, I decided to write a short utility program to read all the 52 individual card files and create one file with them laid out neatly in four rows of cards, one row per suite with each card running from Ace to King.</p>
<p>The individual card .png files were all in one folder with two letter filenames rank and suit in capitals like AS.png (Ace of spades), TH.png (Ten of Hearts and so on).</p>
<p>This 62 line C# program reads all 52 files into RAM in a two-dimension array <strong>cards</strong> (<em>original name eh!</em>) in the method <strong>LoadAllImages()</strong> then in BuildOneImage() it writes them out in the four rows into the bitmap <strong>allcards</strong> then saves them out as one .png format file.</p>
<p>C# makes doing this very easy. In C you would have to write your own file format handling code or use a library like <a title="Link to libpng website" href="http://www.libpng.org/pub/png/libpng.html" target="_blank" rel="noopener noreferrer">libpng</a>.</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 mpics
{
    class Program
    {
        const int CardWidth = 100;
        const int CardHeight = 153;
        const string source = &quot;your path here&quot;; // Path to all 52 card files
        const string dest = &quot;target file here&quot;; // Path + filename for target .png file.
        const string suits = &quot;HCDS&quot;;
        const string ranks = &quot;A23456789TJQK&quot;;

        static Bitmap[,] cards = new Bitmap[13,4];
        static Bitmap allcards = new Bitmap(CardWidth * 13,CardHeight * 4);

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

        private static void BuildOneImage()
        {
            Console.WriteLine();
            var aty = 0.0f;
            using (Graphics g = Graphics.FromImage(allcards))
            {
                for (var y = 0; y &lt; 4; y++)
                {
                    var atx = 0.0f;
                    for (int x = 0; x &lt; 13; x++)
                    {
                        var r = new Rectangle((int)atx, (int)aty, CardWidth, CardHeight);
                        g.DrawImage(cards[x,y],r);
                        atx += CardWidth;
                    }
                    aty += CardHeight;
                }
            }
            allcards.Save(dest, ImageFormat.Png);
        }

        private static void LoadAllImages()
        {
            var i = 0;
            foreach (char c in suits)
            {
                var j = 0;
                foreach (char r in ranks)
                {
                    var s = source + r + c+&quot;.png&quot;;
                    cards[j++,i] = (Bitmap)Bitmap.FromFile(s);
                }
                i++;
            }
        }
    }
}
</code></pre>
<p>Don&#8217;t forget to set the <strong>source</strong> and <strong>dest</strong> path constants. This was compiled in Visual Studio 2019 and run on Windows 10. The only really important thing I found was using the Rectangle r in <strong>BuildOneImage()</strong>. If I used just atx and aty and didn&#8217;t specify the size of card then <strong>DrawImage</strong>() drew much smaller images into the bitmap. I&#8217;m not sure why as the card images when loaded from disk were 100 wide by 153 deep, the same as specified in the constants <strong>CardWidth</strong> and <strong>CardHeight</strong>.</p>
<p>The card images were originally downloaded from the <a title="Link to American Contract Bridge League" href="http://acbl.mybigcommerce.com/52-playing-cards/" target="_blank" rel="noopener noreferrer">American Contract Bridge League</a> but were much bigger so I scaled them first to 100 x 153 pixels. There are many free playing card images on the web but these are one of the nicer sets.</p>The post <a href="https://learncgames.com/how-to-create-a-big-image-from-a-number-of-smaller-ones/">How to create a big image from a number of smaller ones</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">1095</post-id>	</item>
	</channel>
</rss>
