Skip to content
Matthias Görges edited this page May 29, 2014 · 3 revisions

u8vector->png saves an u8vector image to PNG file.

Parameter Description
data u8vector with image data
fname PNG file to save to
w Image width
h Image height

Example

Example 1: Modify the panda-icon.png from uSquish to remove all RED color.

> (define fname (string-append (system-directory) (system-pathseparator) "panda-icon.png"))
> (define img (png->u8vector fname))
> (let loop ((i 0))
    (if (fx= i (u8vector-length img))   
      #t
      (begin
        (u8vector-set! img i 0)
        (loop (fx+ i (png-stride fname))) 
      )
    )
  )
#t
> (u8vector->png img "panda-changed.png" (png-width fname) (png-height fname))
#t
Clone this wiki locally