- u8*3->u32procedure
- in - PTR8: ptr to unsigned-byte
- in - LEN: int - length of data (image width * height)
- out - PTR32: ptr to unsigned-int32
- returns: number of 32bit pixels (should be equal to LEN)
(import scheme.base chicken.foreign chicken.number-vector leptonic) (include "leptonic-types.scm") (define-external ppx0 ppix (pix-read "input.png")) (define data0 (pix-get-data ppx0)) (define w (pix-get-width ppx0)) (define h (pix-get-height ppx0)) (define len (* w h)) (define v8 (make-u8vector (* len 3) 0)) (u32->u8*3 data0 len (location v8)) ;; ... modify v8 ... (define-external ppx1 ppix (pix-create w h 32)) (define data1 (pix-get-data ppx1)) (u8*3->u32 (location v8) len data1) (define fmt (get-implied-fmt "output.png")) (pix-write "output.png" ppx1 fmt) (pix-destroy (location ppx0)) (pix-destroy (location ppx1))Note: if u8vector ‘v8’ is not modified, then output to data1 (in u8*3->u32), will be identical to the input data in data0. IOW “output.png” will be a copy of “input.png”. Comparing the two image files serves as a test of the procedures: if everything is working properly, the image files should be completely indistinguishable.