Created
December 4, 2020 20:17
-
-
Save rgchris/7a715d8be77c3b3400dc21cefc40ea00 to your computer and use it in GitHub Desktop.
Single Pixel in Ren-C (R3C)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: "Single Pixel PNG" | |
Date: 4-Dec-2020 | |
Author: "Christopher Ross-Gill" | |
] | |
chunkify: func [ | |
header [word!] | |
data [binary!] | |
/compress | |
][ | |
header: to-binary form header | |
if compress [ | |
data: deflate/envelope data 'zlib | |
] | |
join-all [ | |
enbin [be + 4] length-of data | |
header | |
data | |
enbin [be +/- 4] checksum/method rejoin [header data] 'crc32 | |
] | |
] | |
png: probe join-all [ | |
#{ | |
89504E47 | |
0D0A1A0A | |
} | |
chunkify 'IHDR #{ | |
00000001 | |
00000001 | |
08 02 00 00 00 | |
} | |
chunkify/compress 'IDAT #{ | |
00 CC0000 | |
} | |
chunkify 'tEXt to binary! [ | |
"Title" 0 "Single Pixel!" | |
] | |
chunkify 'IEND #{} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment