comparison clojure/com/aurellem/run/image.clj @ 518:bb4434c5a8f3

generated gameboy palette for gimp for Dylan.
author Robert McIntyre <rlm@mit.edu>
date Sat, 23 Jun 2012 14:27:01 -0500
parents bc24e4d605e9
children fd1ae0047a1a
comparison
equal deleted inserted replaced
517:bc24e4d605e9 518:bb4434c5a8f3
279 (.setOutput (FileImageOutputStream. target)) 279 (.setOutput (FileImageOutputStream. target))
280 (.write (IIOImage. im nil nil)) 280 (.write (IIOImage. im nil nil))
281 (.dispose)) 281 (.dispose))
282 im)) 282 im))
283 283
284 (defn gen-gimp-palette! []
285 (let [target
286 (File. user-home "proj/vba-clojure/Gameboy-Color.gpl")]
287 (spit
288 target
289 (apply
290 str
291 (concat
292 ["GIMP Palette\n"
293 "Name: GameBoy\n"
294 "#\n"]
295 (map (fn [[r g b]]
296 (format "%3d %3d %3d\n" r g b))
297 (sort (set (vals gb-color-map)))))))))
298
284 (def test-image 299 (def test-image
285 (ImageIO/read 300 (ImageIO/read
286 (File. user-home "/proj/vba-clojure/images/test-gb-image.png"))) 301 (File. user-home "/proj/vba-clojure/images/test-gb-image.png")))
287 302
288 (def test-image-2 303 (def test-image-2
290 (File. user-home "/proj/vba-clojure/images/test-gb-image-2.png"))) 305 (File. user-home "/proj/vba-clojure/images/test-gb-image-2.png")))
291 306
292 (def test-image-color 307 (def test-image-color
293 (ImageIO/read 308 (ImageIO/read
294 (File. user-home "/proj/vba-clojure/images/colors-test.png"))) 309 (File. user-home "/proj/vba-clojure/images/colors-test.png")))
295
296
297
298 310
299 (defn rgb->triplet [rgb] 311 (defn rgb->triplet [rgb]
300 (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16) 312 (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16)
301 g (bit-shift-right (bit-and rgb 0xFF00) 8) 313 g (bit-shift-right (bit-and rgb 0xFF00) 8)
302 b (bit-and rgb 0xFF)] 314 b (bit-and rgb 0xFF)]