((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/stb-image-write" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "sbt-image-write" (p "CHICKEN bindings to " (link "https://github.com/nothings/stb/blob/master/stb_image_write.h" ("stb" (i "image") "write"))) (toc) (section 3 "Repository" (p (link "https://github.com/kristianlm/chicken-stb-image-resize" "https://github.com/kristianlm/chicken-stb-image-resize"))) (section 3 "Requirements" (p "None, " (tt "stb_image_write.h") " v1.09 is embedded in the egg.")) (section 3 "API" (def (sig (procedure " (write-png pixels width height components #!key flip compression stride filter)" (id write-png)) (procedure " (write-jpg pixels width height components #!key flip quality)" (id write-jpg)) (procedure " (write-tga pixels width height components #!key flip rle)" (id write-tga)) (procedure " (write-bmp pixels width height components #!key flip)" (id write-bmp))) (p "Writes the u8vector " (tt "pixels") " to " (tt "(current-output-port)") " using the image format of the procedure name. The pixel format depends on " (tt "components") ", which represents the number of bytes per pixel:") (pre "   1: y8 (gray)\n   2: ya16 (gray + alpha)\n   3: rgb24\n   4: rgba32") (p "Extra parameters are:") (ul (li (tt "flip") " specifies whether to flip the image vertically before outputting") (li "png " (tt "compression") " sets the " (tt "zlib") " compression quality. defaults to 8, try higher values for more compression") (li "png " (tt "stride") " is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels.") (li "png " (tt "filter") " forces a particular " (link "https://en.wikipedia.org/wiki/Portable_Network_Graphics#Filtering" "filter type") " for all scanlines. defaults to trying all and picking the most efficient (" (tt "#f") "), other valid values are 0-4.") (li "jpg " (tt "quality") " specifies lossy compression amount as a percentage (defaults to 80)") (li "tga " (tt "rle") " enables or disable run-length-encoding compression. it is on by default, set to " (tt "#f") " to disable rle compression")) (p "Note that on 32-bit systems, blobs cannot be larger than 16M. This also limits image sizes as pixel data is stored in a blob."))) (section 3 "Example" (highlight scheme "    \n(with-output-to-file \"red.png\"\n  (lambda ()\n    (write-png 16 9 4\n           (let ((r '(255   0   0 255))\n             (b '(  0   0 255 128))\n             (_ '(  0   0   0   0)))\n         (list->u8vector\n          (flatten\n           (list b b b b b b b b b b b b b b b b\n             b _ _ _ _ _ _ _ _ _ _ _ _ _ _ b\n             b _ _ r r r _ r r r _ r r _ _ b\n             b _ _ r _ r _ r _ _ _ r _ r _ b\n             b _ _ r r r _ r r r _ r _ r _ b\n             b _ _ r r _ _ r _ _ _ r _ r _ b\n             b _ _ r _ r _ r r r _ r r _ _ b\n             b _ _ _ _ _ _ _ _ _ _ _ _ _ _ b\n             b b b b b b b b b b b b b b b b)))))))")) (section 3 "TODO" (ul (li "test png stride") (li "see if it's possible to write data to port without copying memory"))) (section 3 "Source" (p "The source is located " (link "https://github.com/kristianlm/chicken-stb-image-write" "here") "."))))