Skip to content

Instantly share code, notes, and snippets.

@rgchris
Created December 4, 2020 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgchris/7a715d8be77c3b3400dc21cefc40ea00 to your computer and use it in GitHub Desktop.
Save rgchris/7a715d8be77c3b3400dc21cefc40ea00 to your computer and use it in GitHub Desktop.
Single Pixel in Ren-C (R3C)
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