 (defn blit-sub-image [app sub-image xoff yoff]
   (let [canvas preview-canvas-elem
         context (.getContext canvas "2d")
-        width (get-in @app [:main-app :canvas-width])
-        height (get-in @app [:main-app :canvas-height])
-        zoom-factor (get-in @app [:zoom-factor])
+        width (get-in app [:main-app :canvas-width])
+        height (get-in app [:main-app :canvas-height])
+        zoom-factor (get-in app [:zoom-factor])
         pixel-size zoom-factor
         sub-image-pixel-count (count (:image-data sub-image))]
     (dotimes [x sub-image-pixel-count]


    om/IDidUpdate
      (did-update [_ _ _]
          (clear-preview-canvas)
          (when (= (get-in app [:tools :paint-tool]) :selection)
            (draw-selection-outline app owner)))

    om/IWillMount
    (will-mount [_]

             (* y1 zoom-factor)
             (* (- x2 x1) zoom-factor)
             (* (- y2 y1) zoom-factor))
          (blit-sub-image @app (om/get-state owner :selection-image) blit-x blit-y)))))))


;; =============================================================================
