Skip to content

pt300/crot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crot

Rotating memes in terminal

Compiling

You don't need any special libs for that. So don't worry.

Just cd into Release/ directory and make all.

Running

To run crot you need to specify path to proper MEME file as 1st argument.

MEME files' structure

MEME files consist of 4 bytes magic MEME and 1 byte which specifies type of file and 60x60 image data.

There are 2 of 'em:

  • 0x00 - monochrome B/W
  • 0x01 - 8bit RGB

For monochrome MEMEs these 5 header bytes are followed by 450 bytes of image.

Each byte represents 8 pixels. So one row fits into 7 bytes and 4 bits and entire image fits into 450 bytes.

Encoding is little-endian.

Because a lot of people might not even understand that rambling, here's code I use to access data of said images.

int get(int x, int y, int width, uint8_t* mem) {
	return (*(mem+(x+y*width)/8)>>(x+y*width)%8)&1;
}

void set(int data, int x, int y, int width, uint8_t* mem) {
	if(data) {
		*(mem+(x+y*width)/8)|=1<<((x+y*width)%8);
	}
	else {
		*(mem+(x+y*width)/8)&=~(1<<((x+y*width)%8));
	}
}

RGB MEMEs image data is 10800 bytes long and it's just 8bit rgb data without any special encoding.


Example MEME files are contained in memes/ directory.