Skip to content

WooHoo Direct Image Serving From the Olduino

April 4, 2015

15-04-04 chrome

Yesterday I was partially successful in serving an image from the Olduino memory in response to a browser request. To repeat the thing that seems intriguing to me, when a browser requests an image, the server sends a header saying, in effect “here you go” and then sends the raw binary data for the image. I don’t know how i thought it worked but i thought there was more to it than that!

The picture above is from the chrome browser on an android tablet. The image was sent from the 1802’s memory as was the “favicon” tiny starship image that you see in the browser tab(for contrast, see the heart in the other browser tab being used by someone else entirely). The favicon is a 16X16 monochrome bitmap and the total data sent is a couple of hundred bytes. The starship bitmap is about 128X100 and the total data sent is around 1500 bytes.

These are fun but my interest isn’t in sending fixed images, it’s in generating them on the fly programatically. Something like a game of life where the next generation gets calculated when some browser asks for it.

The other neat thing I’ve realized from this is more about how browsers and servers work. When you put something in the address bar like http://www.whatever.com/whatever.html, you think you’re just mechanically getting whatever.html but, in fact, the server is just looking at the text in the url and totally independently deciding what to send back. In this case, my server is just looking for the characters “bitmap” and dispatching a routine that sends the memory contents. There IS no entity called bitmap.

  			if (strncmp((char *)buf,"POST /",6)==0){
  				bagelsinit(); //initialize game, send the form
			}
			else if (strncmp((char *)buf,"GET /favicon",12)==0){
  				sendfavicon();
			}
			else if (strncmp((char *)buf,"GET /bitmap",11)==0){
		  		sendbmp();
			}
  			else if (strncmp((char *)buf,"GET /?G=",8)==0){
				bagelsturn();	//give player his turn
void sendfavicon(){
	printf("sending the icon\n");
	sendconst(iconhdr); 	// Now Send a header
	sendbin(starshipicon);//and the binary data!
}
void sendbmp(){
	printf("sending the bmp\n");
	sendconst(bmphdr); 	// Now Send a header
	sendbin(starshipbmp);//and the binary data!
}
char iconhdr[]="HTTP/1.1 200 OK\r\n\r\n";
char starshipicon[]={//2nd try
0x00,0x00,0x01,0x00,0x01,0x00,0x10,0x10,0x02,0x00,
0x01,0x00,0x01,0x00,0xB0,0x00,0x00,0x00,0x16,0x00,
0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
0x20,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x0F,0xF0,
0x00,0x00,0x07,0xF0,0x00,0x00,0x0C,0x40,0x00,0x00,
0x18,0x40,0x00,0x00,0xFE,0x40,0x00,0x00,0x10,0xFF,
0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
char bmphdr[]="HTTP/1.0 200 OK\r\nContent-Type: image/bmp\r\n\r\n";
char starshipbmp[]={0x42,0x4D,0x2E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0x3E,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x5F,0x00,0x00,0x00,0x01,0x00,0x01,0x00,
0x00,0x00,0x00,0x00,0xF0,0x05,0x00,0x00,0x87,0x1D,
0x00,0x00,0x87,0x1D,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0xFF,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xC0,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0xFF,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xC0,0x00,0xFF,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,
0x00,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0F,0x00,0x00,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0x0F,0xFF,0xF0,0x00,0x00,0x03,0x00,
0x3F,0xCF,0xF3,0x00,0x00,0x00,0x00,0x00,0x3F,0x0F,
0xFF,0xF0,0x00,0x00,0x03,0x00,0x3F,0xCF,0xF3,0x00,
0x00,0x00,0x00,0x00,0x3F,0x0F,0xFF,0xF0,0x00,0x00,
0x03,0x00,0x3F,0xCF,0xF3,0x00,0x00,0x00,0x00,0x00,
0x3F,0x0F,0xFF,0xF0,0x00,0x00,0x03,0x00,0x3F,0xCF,
0xF3,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x03,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,
0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x30,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,
0x00,0x00,0x00,0x00,0x03,0x00,0x30,0x0C,0x03,0x00,
0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,
0x03,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,
0x03,0xC0,0x3F,0xFF,0xFF,0xF0,0xFF,0x00,0x3F,0x0C,
0x03,0xF0,0x00,0x00,0x00,0x00,0x03,0xC0,0x3F,0xFF,
0xFF,0xF0,0xFF,0x00,0x3F,0x0C,0x03,0xF0,0x00,0x00,
0x00,0x00,0x03,0xC0,0x3F,0xFF,0xFF,0xF0,0xFF,0x00,
0x3F,0x0C,0x03,0xF0,0x00,0x00,0x00,0x00,0x03,0xC0,
0x3F,0xFF,0xFF,0xF0,0xFF,0x00,0x3F,0x0C,0x03,0xF0,
0x00,0x00,0x00,0x00,0x00,0x3F,0xC3,0x00,0x00,0x30,
0xC0,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xC3,0x00,0x00,0x30,0xC0,0x00,0x30,0x0C,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xC3,0x00,
0x00,0x30,0xC0,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xC3,0x00,0x00,0x30,0xC0,0x00,
0x30,0x0C,0x03,0x00,0x00,0x00,0x00,0xFF,0x00,0xC0,
0x0C,0x00,0x00,0x30,0xC0,0x00,0x3F,0xCC,0x03,0xFC,
0x00,0x00,0x00,0xFF,0x00,0xC0,0x0C,0x00,0x00,0x30,
0xC0,0x00,0x3F,0xCC,0x03,0xFC,0x00,0x00,0x00,0xFF,
0x00,0xC0,0x0C,0x00,0x00,0x30,0xC0,0x00,0x3F,0xCC,
0x03,0xFC,0x00,0x00,0x00,0xFF,0x00,0xC0,0x0C,0x00,
0x00,0x30,0xC0,0x00,0x3F,0xCC,0x03,0xFC,0x00,0x00,
0x0F,0xFF,0xF3,0x00,0x30,0x00,0x00,0x30,0xC0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xF3,0x00,
0x30,0x00,0x00,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0F,0xFF,0xF3,0x00,0x30,0x00,0x00,0x30,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,
0xF3,0x00,0x30,0x00,0x00,0x30,0xC0,0x00,0x00,0x00,
0x00,0x00,0x3F,0xFF,0xF0,0x00,0x0F,0xFF,0xFC,0x00,
0x00,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
0xF0,0x00,0x0F,0xFF,0xFC,0x00,0x00,0x30,0xC0,0x00,
0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,0x00,0x0F,0xFF,
0xFC,0x00,0x00,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF0,0x00,0x0F,0xFF,0xFC,0x00,0x00,0x30,
0xC0,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0xFF,
0x00,0x00,0x03,0x00,0x00,0x30,0xC0,0x00,0x00,0x00,
0x00,0x00,0x30,0x00,0x00,0xFF,0x00,0x00,0x03,0x00,
0x00,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x30,0x00,
0x00,0xFF,0x00,0x00,0x03,0x00,0x00,0x30,0xC0,0x00,
0x00,0x00,0x00,0x00,0x30,0x00,0x00,0xFF,0x00,0x00,
0x03,0x00,0x00,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF0,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xF0,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x3F,0xFF,0xF0,0x00,
0x0F,0xFF,0xFC,0x00,0xFF,0xF0,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFC,0x3F,0xFF,0xF0,0x00,0x0F,0xFF,0xFC,0x00,
0xFF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x3F,0xFF,
0xF0,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xF0,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x3F,0xFF,0xFC,0x00,
0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,
0x00,0x00,0x3F,0xFF,0xFC,0x00,0x00,0x03,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x3F,0xFF,
0xFC,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0C,0x00,0x00,0x3F,0xFF,0xFC,0x00,0x00,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,
0x00,0x3C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3C,0x00,0x00,
0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x03,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3C,
0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xCF,0xF3,0xFC,0xC0,0xCC,
0x33,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xCF,0xF3,0xFC,0xC0,0xCC,0x33,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xCF,0xF3,0xFC,
0xC0,0xCC,0x33,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xCF,0xF3,0xFC,0xC0,0xCC,0x33,0xFC,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xCC,
0x30,0x0C,0xC0,0xCC,0x33,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0xCC,0x30,0x0C,0xC0,0xCC,
0x33,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x30,0xCC,0x30,0x0C,0xC0,0xCC,0x33,0x0C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xCC,0x30,0x0C,
0xC0,0xCC,0x33,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x0C,0x33,0xFC,0xCC,0xCF,0xF3,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0C,
0x33,0xFC,0xCC,0xCF,0xF3,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x0C,0x33,0xFC,0xCC,0xCF,
0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x30,0x0C,0x33,0xFC,0xCC,0xCF,0xF3,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xCC,0x33,0x00,
0xF3,0xCC,0x33,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0xCC,0x33,0x00,0xF3,0xCC,0x33,0x0C,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xCC,
0x33,0x00,0xF3,0xCC,0x33,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0xCC,0x33,0x00,0xF3,0xCC,
0x33,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xCF,0xF3,0xFC,0xF3,0xCF,0xF3,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xCF,0xF3,0xFC,
0xF3,0xCF,0xF3,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xCF,0xF3,0xFC,0xF3,0xCF,0xF3,0xFC,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xCF,
0xF3,0xFC,0xF3,0xCF,0xF3,0xFC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00
};
Advertisements

From → web server

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: