<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Aborders-black-on-white.c</id>
	<title>Code:borders-black-on-white.c - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Aborders-black-on-white.c"/>
	<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:borders-black-on-white.c&amp;action=history"/>
	<updated>2026-04-23T06:58:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:borders-black-on-white.c&amp;diff=171&amp;oldid=prev</id>
		<title>Elie at 18:10, 7 August 2022</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:borders-black-on-white.c&amp;diff=171&amp;oldid=prev"/>
		<updated>2022-08-07T18:10:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:10, 7 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Generates the image [[:File:borders-black-on-white.png|borders-black-on-white.png]] from raw data [[:File:countries.data-int16-8640x4320|countries.data-int16-8640x4320]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define WIDTH 8640&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define WIDTH 8640&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:borders-black-on-white.c&amp;diff=169&amp;oldid=prev</id>
		<title>Elie: Created page with &quot;&lt;syntaxhighlight lang=&quot;c&quot;&gt; #define WIDTH 8640 #define HEIGHT 4320 #define IN_FILE &quot;data/countries.data-int16-8640x4320&quot; #define OUT_FILE &quot;data/borders-black-on-white.png&quot;  #include &lt;stdio.h&gt; #define STB_IMAGE_WRITE_IMPLEMENTATION #include &quot;stb_image_write.h&quot;  int main() {  short          *in = malloc(WIDTH*HEIGHT*sizeof(short));  unsigned char *out = malloc(WIDTH*HEIGHT*sizeof(unsigned char));  if (!in || !out) {   printf(&quot;Not enough memory\n&quot;);   free(in); free(out);...&quot;</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:borders-black-on-white.c&amp;diff=169&amp;oldid=prev"/>
		<updated>2022-08-07T08:11:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt; #define WIDTH 8640 #define HEIGHT 4320 #define IN_FILE &amp;quot;data/countries.data-int16-8640x4320&amp;quot; #define OUT_FILE &amp;quot;data/borders-black-on-white.png&amp;quot;  #include &amp;lt;stdio.h&amp;gt; #define STB_IMAGE_WRITE_IMPLEMENTATION #include &amp;quot;stb_image_write.h&amp;quot;  int main() {  short          *in = malloc(WIDTH*HEIGHT*sizeof(short));  unsigned char *out = malloc(WIDTH*HEIGHT*sizeof(unsigned char));  if (!in || !out) {   printf(&amp;quot;Not enough memory\n&amp;quot;);   free(in); free(out);...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#define WIDTH 8640&lt;br /&gt;
#define HEIGHT 4320&lt;br /&gt;
#define IN_FILE &amp;quot;data/countries.data-int16-8640x4320&amp;quot;&lt;br /&gt;
#define OUT_FILE &amp;quot;data/borders-black-on-white.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#define STB_IMAGE_WRITE_IMPLEMENTATION&lt;br /&gt;
#include &amp;quot;stb_image_write.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
 short          *in = malloc(WIDTH*HEIGHT*sizeof(short));&lt;br /&gt;
 unsigned char *out = malloc(WIDTH*HEIGHT*sizeof(unsigned char));&lt;br /&gt;
 if (!in || !out) {&lt;br /&gt;
  printf(&amp;quot;Not enough memory\n&amp;quot;);&lt;br /&gt;
  free(in); free(out);&lt;br /&gt;
  return 1;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // load data&lt;br /&gt;
 printf(&amp;quot;Reading %s\n&amp;quot;, IN_FILE);&lt;br /&gt;
 FILE *f = fopen(IN_FILE,&amp;quot;r&amp;quot;);  if (!f) { perror(IN_FILE); return 2; }&lt;br /&gt;
 if (!fread(in, sizeof(in[0]), WIDTH*HEIGHT, f)) printf(&amp;quot;Input file is incomplete. Output will probably be garbage lol\n&amp;quot;);&lt;br /&gt;
 fclose(f);&lt;br /&gt;
 &lt;br /&gt;
 // simplest edge-detection algorithm i can think of lol&lt;br /&gt;
 printf(&amp;quot;Detecting edges\n&amp;quot;);&lt;br /&gt;
 int i; for (i=0; i&amp;lt;WIDTH; i++) out[i]=255;&lt;br /&gt;
 for (; i&amp;lt;WIDTH*(HEIGHT-1); i++) {&lt;br /&gt;
  if (in[i] != in[i+1]&lt;br /&gt;
   || in[i] != in[i-1]&lt;br /&gt;
   || in[i] != in[i-WIDTH]&lt;br /&gt;
   || in[i] != in[i+WIDTH]) out[i]=0;&lt;br /&gt;
  else out[i]=255;&lt;br /&gt;
 }&lt;br /&gt;
 for (; i&amp;lt;WIDTH*HEIGHT; i++) out[i]=255; // top and bottom rows of pixels are ignored, for simplicity sake. The dataset doesn't have edges there anyway.&lt;br /&gt;
 &lt;br /&gt;
 // write file and done&lt;br /&gt;
 int r=0;&lt;br /&gt;
 printf(&amp;quot;Writing %s\n&amp;quot;, OUT_FILE);&lt;br /&gt;
 free(in);&lt;br /&gt;
 if (!stbi_write_png(OUT_FILE, WIDTH, HEIGHT, 1, out, WIDTH)) { perror(OUT_FILE); r=3; }&lt;br /&gt;
 free(out);&lt;br /&gt;
 return r;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
</feed>