From 8ceb7bce2ad869c7be80c13fbe592a43c119729f Mon Sep 17 00:00:00 2001 From: heyarne Date: Thu, 20 Aug 2020 22:40:41 +0200 Subject: [PATCH] We can actually display the image we fetched :) --- src/heyarne/vanilla_sky/tiptaps.clj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/heyarne/vanilla_sky/tiptaps.clj b/src/heyarne/vanilla_sky/tiptaps.clj index 3772b40..3dd5213 100644 --- a/src/heyarne/vanilla_sky/tiptaps.clj +++ b/src/heyarne/vanilla_sky/tiptaps.clj @@ -105,10 +105,16 @@ ;; first multipart alternative to a `BufferedImage` that we can use ;; with Clojure2d. +(require '[clojure2d.core :as c2d]) + (defn byte-array->image [bs] (with-open [in (java.io.ByteArrayInputStream. bs)] (javax.imageio.ImageIO/read in))) (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")