 (defn get-image-dimensions [^TaggedImage tagged-image]
   [(MDUtils/getWidth (.tags tagged-image))
    (MDUtils/getHeight (.tags tagged-image))])
-
-(defn buffered-image
-  ([[w h] pixels]
-    (let [image (ImageIO/read (ByteArrayInputStream. pixels))
-          raster (cast WritableRaster (.getData image))]
-      (.setPixels raster 0 0 w h pixels)
-      image))
-  ([^TaggedImage tagged-image]
-    (buffered-image (get-image-dimensions tagged-image) (.pix tagged-image))))
 
 (defn enable-anti-aliasing
   ([^Graphics g]

                          (update-size)))))
  size-atom)

(defn reflect-changes [canvas screen-state]
  (add-watch screen-state "display"
    (fn [_ _ _ new-state]
      (.repaint canvas))))     

(defn main-canvas [screen-state]
  (doto
    (proxy [Canvas] []
      (paint [^Graphics g] (paint-screen this screen-state)))
    (.setBackground Color/BLACK)))
    
(defn main-frame []

(defn awt-image [^TaggedImage tagged-image]
  (.getImage (ImagePlus. "" (ImageUtils/makeProcessor tagged-image))))

(defn get-tile [[nx ny nz nc nt nzoom]]
  (grab-tagged-image))

(defn add-tile [tile-map indices]
  (assoc tile-map indices (get-tile indices)))

(defn add-to-visible-tiles [visible-tiles indices]
  (send-off visible-tiles add-tile indices))

;; gui utilities
