On Wed, Feb 02, 2005 at 04:18:46PM -0500, Raymond Toy wrote: > > I tried your code I I get an error as well. Don't know why, but it > works much better to use > > (defun foo (name) > (with-alien ((filename c-string) > (width int) > (height int) > (image_array (* (* unsigned-char)))) > > (setf filename name) > > (extract-image filename > (addr width) > (addr height) > (addr image_array)) > > (setf filename "del.jpg") > > (save-image filename width height image_array))) > > and compile the file and run (foo "image"). At least when I do this, > I get a black-and-white version of the original image.
Y, putting with-alien inside a function gives no trouble. But to get a b&w version of any image, you must have uncommented the following lines: ;; If the pixel value is < 155, make it 0 i.e. black. ;; ( dotimes ( h height ) ;; ( dotimes ( w width ) ;; ( if ( < ;; ( array2d image_array h w ) ;; 155 ) ;; ( setf ( array2d image_array h w ) 0 ) ;; T ))) - these come before (setf filename "del.jpg"). My main confusion was, why things don't work if these are commented. One thing to note is, if these are commented then there's no use (?) of the variables like 'height', 'width' etc. except being passed as arguments to functions like save-image.
