<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Try this:<div><br></div><div><div>;;; Binding Block</div><div>(defmacro bb (&rest body)</div><div> (cond</div><div> ((null (rst body)) (fst body))</div><div> ((consp (1st body))</div><div> `(progn ,(1st body) (bb ,@(rst body))))</div><div> ((not (symbolp (1st body)))</div><div> (error "~S is not a valid variable name" (1st body)))</div><div> ((eq (1st body) ':mv)</div><div> (if (symbolp (2nd body))</div><div> `(let ((,(2nd body) (multiple-value-list ,(3rd body))))</div><div> (bb ,@(rrrst body)))</div><div> `(multiple-value-bind ,(2nd body) ,(3rd body)</div><div> (bb ,@(rrrst body)))))</div><div> ((eq (1st body) :db)</div><div> `(destructuring-bind ,(2nd body) ,(3rd body)</div><div> (declare (special ,@(find-specials (2nd body))))</div><div> (bb ,@(rrrst body))))</div><div> ; BUG: 1-arg assumption fails for with-slots</div><div> ((eq (1st body) :with)</div><div> `(,(intern (format nil "WITH-~A" (2nd body)) (symbol-package (2nd body)))</div><div> ,(3rd body) (bb ,@(rrrst body))))</div><div> ((keywordp (1st body))</div><div> (error "~S is not a valid binding keyword" (1st body)))</div><div> (t `(let ((,(1st body) ,(2nd body)))</div><div> (declare (special ,@(find-specials (1st body))))</div><div> (bb ,@(rrst body))))))</div></div><div><br></div><div><div>(defun image-from-url (url)</div><div> (#/initWithContentsOfURL: (#/alloc ns:ns-image)</div><div> (#/URLWithString: ns:ns-url url)))</div><div><br></div><div>(defun image-from-file (filename)</div><div> (#/initWithData: (#/alloc ns:ns-image)</div><div> (#/dataWithContentsOfFile: ns:ns-data filename)))</div><div><br></div><div>(defun image-bitmap (img)</div><div> (or</div><div> (loop</div><div> with e = (#/objectEnumerator (#/representations img))</div><div> as rep = (#/nextObject e)</div><div> until (%null-ptr-p rep)</div><div> if (typep rep ns:ns-bitmap-image-rep) return rep)</div><div> (bb</div><div> :with focused-image img</div><div> :db (x . y) (image-size img)</div><div> (#/initWithFocusedViewRect: (#/alloc ns:ns-bitmap-image-rep)</div><div> (ns:make-ns-rect 0 0 x y)))))</div><div><br></div><div>(defun bitmap-pixels (rep)</div><div> (bb</div><div> :db (x . y) (image-size rep)</div><div> ptr (#/bitmapData rep)</div><div> bpr (#/bytesPerRow rep) ; Could be padded</div><div> bpp (/ (#/bitsPerPixel rep) 8)</div><div> a (make-array (list y x bpp) :element-type '(unsigned-byte 8))</div><div> (dotimes (i x a)</div><div> (dotimes (j y)</div><div> (dotimes (k bpp)</div><div> (setf (aref a j i k) (%get-byte ptr (+ (* i bpp) (* j bpr) k))))))))</div><div><br></div><div>(defun image-pixels (img) (bitmap-pixels (image-bitmap img)))</div><div><br></div><div>(defun image2jpeg (img &optional (compression 0.9))</div><div> (#/representationUsingType:properties:</div><div> (image-bitmap img)</div><div> #$NSJPEGFileType</div><div> (#/dictionaryWithObject:forKey: ns:ns-dictionary</div><div> (#/numberWithFloat: ns:ns-number compression)</div><div> #&NSImageCompressionFactor)))</div><div><br></div><div><div>On Jun 3, 2008, at 12:59 PM, Andrew Shalit wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Anyone have time to put the following CCL utility together for Russell Kirsch (<a href="http://home.comcast.net/~rakirsch/)?">http://home.comcast.net/~rakirsch/)?</a><br><br><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>From: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">"Russell A. Kirsch" <<a href="mailto:rakirsch@acm.org">rakirsch@acm.org</a>></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><b>...</b></font></div> </div><div>Please tell me how to do the following:<br>Read an image file (Tiff or Pict) from disk into a 2 dimensional array in CCL and then Output a processed two dimensional array to a Tiff or Pict file on the disk. In the CCL documentation I can only find description of one dimensional vector input.<br><br>Russell<br><br></div></blockquote></div></div>_______________________________________________<br>Openmcl-devel mailing list<br><a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>http://clozure.com/mailman/listinfo/openmcl-devel<br></blockquote></div><br></div></body></html>