Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

sbt-image-write

CHICKEN bindings to stbimagewrite

  1. Outdated egg!
  2. sbt-image-write
    1. Repository
    2. Requirements
    3. API
    4. Example
    5. TODO
    6. Source

Repository

https://github.com/kristianlm/chicken-stb-image-resize

Requirements

None, stb_image_write.h v1.09 is embedded in the egg.

API

[procedure] (write-png pixels width height components #!key flip compression stride filter)
[procedure] (write-jpg pixels width height components #!key flip quality)
[procedure] (write-tga pixels width height components #!key flip rle)
[procedure] (write-bmp pixels width height components #!key flip)

Writes the u8vector pixels to (current-output-port) using the image format of the procedure name. The pixel format depends on components, which represents the number of bytes per pixel:

   1: y8 (gray)
   2: ya16 (gray + alpha)
   3: rgb24
   4: rgba32

Extra parameters are:

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.

Example

    
(with-output-to-file "red.png"
  (lambda ()
    (write-png 16 9 4
           (let ((r '(255   0   0 255))
             (b '(  0   0 255 128))
             (_ '(  0   0   0   0)))
         (list->u8vector
          (flatten
           (list b b b b b b b b b b b b b b b b
             b _ _ _ _ _ _ _ _ _ _ _ _ _ _ b
             b _ _ r r r _ r r r _ r r _ _ b
             b _ _ r _ r _ r _ _ _ r _ r _ b
             b _ _ r r r _ r r r _ r _ r _ b
             b _ _ r r _ _ r _ _ _ r _ r _ b
             b _ _ r _ r _ r r r _ r r _ _ b
             b _ _ _ _ _ _ _ _ _ _ _ _ _ _ b
             b b b b b b b b b b b b b b b b)))))))

TODO

Source

The source is located here.