Ticket #16472: 16472.load_all.patch

File 16472.load_all.patch, 4.0 KB (added by taylor.smock, 4 years ago)

DO NOT APPLY -- load the entire image into memory, with attendent calculations (this is very expensive). There is also a UI bug with this patch.

  • src/org/openstreetmap/josm/gui/layer/geoimage/viewers/projections/Equirectangular.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/viewers/projections/Equirectangular.java b/src/org/openstreetmap/josm/gui/layer/geoimage/viewers/projections/Equirectangular.java
    index f76b252344..de69efdc14 100644
    a b public class Equirectangular extends ComponentAdapter implements IImageViewer {  
    4747        g.drawImage(currentOffscreenImage, target.x, target.y, target.x + target.width, target.y + target.height,
    4848                visibleRect.x, visibleRect.y, visibleRect.x + visibleRect.width, visibleRect.y + visibleRect.height,
    4949                null);
     50        if (currentOffscreenImage.getWidth() != image.getWidth() || currentOffscreenImage.getHeight() != image.getHeight()) {
     51            this.updateBufferedImageSize(image.getWidth(), image.getHeight());
     52        }
    5053    }
    5154
    5255    @Override
    public class Equirectangular extends ComponentAdapter implements IImageViewer {  
    6265    @Override
    6366    public void componentResized(ComponentEvent e) {
    6467        final Component imgDisplay = e.getComponent();
    65         if (e.getComponent().getWidth() > 0
    66                 && e.getComponent().getHeight() > 0) {
    67             // FIXME: Do something so that the types of the images are the same between the offscreenImage and
    68             // the image entry
    69             final CameraPlane currentCameraPlane;
    70             synchronized (this) {
    71                 currentCameraPlane = this.cameraPlane;
    72             }
    73             final BufferedImage temporaryOffscreenImage = new BufferedImage(imgDisplay.getWidth(), imgDisplay.getHeight(),
    74                     BufferedImage.TYPE_4BYTE_ABGR);
    75 
    76             Vector3D currentRotation = null;
    77             if (currentCameraPlane != null) {
    78                 currentRotation = currentCameraPlane.getRotation();
    79             }
    80             final CameraPlane temporaryCameraPlane = new CameraPlane(imgDisplay.getWidth(), imgDisplay.getHeight());
    81             if (currentRotation != null) {
    82                 temporaryCameraPlane.setRotation(currentRotation);
    83             }
    84             synchronized (this) {
    85                 this.cameraPlane = temporaryCameraPlane;
    86                 this.offscreenImage = temporaryOffscreenImage;
    87             }
     68        if (imgDisplay.getWidth() > 0 && imgDisplay.getHeight() > 0) {
     69            this.updateBufferedImageSize(imgDisplay.getWidth(), imgDisplay.getHeight());
    8870            if (imgDisplay instanceof ImageDisplay) {
    8971                ((ImageDisplay) imgDisplay).updateVisibleRectangle();
    9072            }
    public class Equirectangular extends ComponentAdapter implements IImageViewer {  
    9274        }
    9375    }
    9476
     77    /**
     78     * Update the buffered image size
     79     * @param width The width to use
     80     * @param height The height to use
     81     */
     82    private void updateBufferedImageSize(final int width, final int height) {
     83        final CameraPlane currentCameraPlane;
     84        synchronized (this) {
     85            currentCameraPlane = this.cameraPlane;
     86        }
     87        // FIXME: Do something so that the types of the images are the same between the offscreenImage and
     88        // the image entry
     89        final BufferedImage temporaryOffscreenImage = new BufferedImage(width, height,
     90                BufferedImage.TYPE_4BYTE_ABGR);
     91
     92        Vector3D currentRotation = null;
     93        if (currentCameraPlane != null) {
     94            currentRotation = currentCameraPlane.getRotation();
     95        }
     96        final CameraPlane temporaryCameraPlane = new CameraPlane(width, height);
     97        if (currentRotation != null) {
     98            temporaryCameraPlane.setRotation(currentRotation);
     99        }
     100        synchronized (this) {
     101            this.cameraPlane = temporaryCameraPlane;
     102            this.offscreenImage = temporaryOffscreenImage;
     103        }
     104    }
     105
    95106    @Override
    96107    public void mouseDragged(final Point from, final Point to, ImageDisplay.VisRect currentVisibleRect) {
    97108        if (from != null && to != null) {