We can actually display the image we fetched :)

This commit is contained in:
heyarne 2020-08-20 22:40:41 +02:00
commit 8ceb7bce2a

View file

@ -105,10 +105,16 @@
;; first multipart alternative to a `BufferedImage` that we can use ;; first multipart alternative to a `BufferedImage` that we can use
;; with Clojure2d. ;; with Clojure2d.
(require '[clojure2d.core :as c2d])
(defn byte-array->image [bs] (defn byte-array->image [bs]
(with-open [in (java.io.ByteArrayInputStream. bs)] (with-open [in (java.io.ByteArrayInputStream. bs)]
(javax.imageio.ImageIO/read in))) (javax.imageio.ImageIO/read in)))
(def img (byte-array->image (:body first-multipart-chunk))) (def img (byte-array->image (:body first-multipart-chunk)))
(def canvas (c2d/canvas (c2d/width img) (c2d/height img)))
(require '[clojure2d.core :as c2d]) (c2d/with-canvas [c canvas]
(c2d/image c img))
(c2d/show-window canvas "Hello World")