Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Last active August 29, 2015 13:56
Show Gist options
  • Save pcarrier/9081306 to your computer and use it in GitHub Desktop.
Save pcarrier/9081306 to your computer and use it in GitHub Desktop.

X11 root window default texture in PNG

Compile with grep -vE '#|>' x11.md | xxd -p -r > x11.png
Result visible here

PNG header

8950 4e47 0d0a 1a0a

IHDR

Chunk header

Chunk length (4 bytes): 13 bytes

0000000D

Chunk type (4 bytes):

"IHDR" in ASCII

49484452

Payload

Width (4 bytes)

00 00 00 04

Height (4 bytes)

00000004

Bit depth (1 byte): 1 bit

01

Colour type (1 byte): greyscale

00

Compression method (1 byte): deflate/inflate (no choice)

00

Filter method (1 byte): adaptive filtering (no choice)

00

Interlace method (1 byte): no interlace

00

CRC, excludes length (4 bytes):

Can be calculated with echo 'obase=16;' (echo 4948445200000004000000040100000000|xxd -r -p|cksum -o 3|cut -d' ' -f1)|bc

818AA3D3

IDAT

Chunk header

Chunk length (4 bytes): 16

00000010

Chunk type (4 bytes):

"IDAT" in ASCII

49444154

Payload:

Line by line, 0 for black, 1 for white: 0b1000, 0b0100, 0b0001, 0b0010
Padded lines: 0b10000000 0b01000000 0b00010000 0b00100000 = 0x80, 0x40, 0x10, 0x20
Prefix line with None filter, 0x00: 0x00, 0x80, 0x00, 0x40, 0x00, 0x10, 0x00, 0x20
Then apply DEFLATE with ruby -rzlib 'puts Zlib.deflate([0x00, 0x80, 0x00, 0x40, 0x00, 0x10, 0x00, 0x20].pack('C*')).unpack('H*')'

789c63686070601060500000051800f1

CRC, excludes length (4 bytes)

FA209263

IEND

Chunk header

Chunk length (4 bytes)

Nothing there.

00000000

Chunk type (4 bytes)

"IEND" in ASCII

49 45 4E 44

CRC, excludes length (4 bytes):

AE426082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment