<?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%3Acontinents-black-on-white.c</id>
	<title>Code:continents-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%3Acontinents-black-on-white.c"/>
	<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:continents-black-on-white.c&amp;action=history"/>
	<updated>2026-07-30T01:53:12Z</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:continents-black-on-white.c&amp;diff=352&amp;oldid=prev</id>
		<title>Elie: Created page with &quot;Generates a simple world map of the continents. : Input: :File:countries.data-int16-8640x4320 : Output: :File:continents-black-on-white.png : Code dependency: Code:stb_image_write.h ==Code== &lt;syntaxhighlight lang=&quot;c&quot;&gt; // Generates a black-and-white PNG world map of the continents, using NASA GPWv4 country indicator data #define IN_FILE &quot;data/countries.data-int16-8640x4320&quot; #define OUT_FILE &quot;data/continents-black-on-white.png&quot; #define INPUT_WIDTH 8640 #define...&quot;</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:continents-black-on-white.c&amp;diff=352&amp;oldid=prev"/>
		<updated>2022-09-01T05:52:12Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Generates a simple world map of the continents. : Input: &lt;a href=&quot;/File:countries.data-int16-8640x4320&quot; title=&quot;File:countries.data-int16-8640x4320&quot;&gt;File:countries.data-int16-8640x4320&lt;/a&gt; : Output: &lt;a href=&quot;/File:continents-black-on-white.png&quot; title=&quot;File:continents-black-on-white.png&quot;&gt;File:continents-black-on-white.png&lt;/a&gt; : Code dependency: &lt;a href=&quot;/Code:stb_image_write.h&quot; title=&quot;Code:stb image write.h&quot;&gt;Code:stb_image_write.h&lt;/a&gt; ==Code== &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt; // Generates a black-and-white PNG world map of the continents, using NASA GPWv4 country indicator data #define IN_FILE &amp;quot;data/countries.data-int16-8640x4320&amp;quot; #define OUT_FILE &amp;quot;data/continents-black-on-white.png&amp;quot; #define INPUT_WIDTH 8640 #define...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Generates a simple world map of the continents.&lt;br /&gt;
: Input: [[:File:countries.data-int16-8640x4320]]&lt;br /&gt;
: Output: [[:File:continents-black-on-white.png]]&lt;br /&gt;
: Code dependency: [[Code:stb_image_write.h]]&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
// Generates a black-and-white PNG world map of the continents, using NASA GPWv4 country indicator data&lt;br /&gt;
#define IN_FILE &amp;quot;data/countries.data-int16-8640x4320&amp;quot;&lt;br /&gt;
#define OUT_FILE &amp;quot;data/continents-black-on-white.png&amp;quot;&lt;br /&gt;
#define INPUT_WIDTH 8640&lt;br /&gt;
#define INPUT_HEIGHT 4320&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.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;
 unsigned char *bytes = malloc(INPUT_WIDTH*INPUT_HEIGHT);&lt;br /&gt;
 if (!bytes) {&lt;br /&gt;
  printf(&amp;quot;Not enough memory\n&amp;quot;);&lt;br /&gt;
  return -1;&lt;br /&gt;
 }&lt;br /&gt;
 short row[INPUT_WIDTH];&lt;br /&gt;
 FILE* in = fopen(IN_FILE, &amp;quot;r&amp;quot;);&lt;br /&gt;
 if (in == NULL) {&lt;br /&gt;
  perror(IN_FILE);&lt;br /&gt;
  return 1;&lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;Reading %s...\n&amp;quot;, IN_FILE);&lt;br /&gt;
 unsigned char *p = bytes;&lt;br /&gt;
 while (!feof(in)) {&lt;br /&gt;
  int nRead = fread(row, sizeof(short), INPUT_WIDTH, in);&lt;br /&gt;
  if (nRead == 0) break;&lt;br /&gt;
  for (int i=0; i&amp;lt;nRead; i++) {&lt;br /&gt;
   if (row[i] &amp;gt; 0 &amp;amp;&amp;amp; row[i] &amp;lt; 1024)  *(p++) = 0;&lt;br /&gt;
   else                              *(p++) = 255;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 fclose(in);&lt;br /&gt;
 printf(&amp;quot;Writing %s...\n&amp;quot;, OUT_FILE);&lt;br /&gt;
 if (!stbi_write_png(OUT_FILE, INPUT_WIDTH, INPUT_HEIGHT, 1, bytes, INPUT_WIDTH)) {&lt;br /&gt;
  perror(OUT_FILE);&lt;br /&gt;
  return 2;&lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;Done.\n&amp;quot;);&lt;br /&gt;
 free(bytes);&lt;br /&gt;
 return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
</feed>