- Timestamp:
- 2015-01-11T20:03:18+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r7912 r7956 27 27 28 28 import org.openstreetmap.josm.Main; 29 import org.openstreetmap.josm.tools.ExifReader; 29 30 30 31 public class ImageDisplay extends JComponent { … … 103 104 final int h = (int) visibleRect.getHeight(); 104 105 105 outer: { 106 final int hh, ww, q; 107 final double ax, ay; 108 switch (orientation) { 109 case 8: 110 q = -1; 111 ax = w / 2; 112 ay = w / 2; 106 if (ExifReader.orientationNeedsCorrection(orientation)) { 107 final int hh, ww; 108 if (ExifReader.orientationSwitchesDimensions(orientation)) { 113 109 ww = h; 114 110 hh = w; 115 break; 116 case 3: 117 q = 2; 118 ax = w / 2; 119 ay = h / 2; 111 } else { 120 112 ww = w; 121 113 hh = h; 122 break;123 case 6:124 q = 1;125 ax = h / 2;126 ay = h / 2;127 ww = h;128 hh = w;129 break;130 default:131 break outer;132 114 } 133 134 115 final BufferedImage rot = new BufferedImage(ww, hh, BufferedImage.TYPE_INT_RGB); 135 final AffineTransform xform = AffineTransform.getQuadrantRotateInstance(q, ax, ay);116 final AffineTransform xform = ExifReader.getRestoreOrientationTransform(orientation, w, h); 136 117 final Graphics2D g = rot.createGraphics(); 137 118 g.drawImage(image, xform, null); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
r7935 r7956 7 7 import java.awt.Rectangle; 8 8 import java.awt.Toolkit; 9 import java.awt.geom.AffineTransform; 9 10 import java.awt.image.BufferedImage; 10 11 import java.util.ArrayList; … … 13 14 import org.openstreetmap.josm.Main; 14 15 import org.openstreetmap.josm.io.CacheFiles; 16 import org.openstreetmap.josm.tools.ExifReader; 15 17 16 18 public class ThumbsLoader implements Runnable { … … 79 81 return null; 80 82 } 83 84 final int w = img.getWidth(null); 85 final int h = img.getHeight(null); 86 final int hh, ww; 87 if (ExifReader.orientationSwitchesDimensions(entry.getExifOrientation())) { 88 ww = h; 89 hh = w; 90 } else { 91 ww = w; 92 hh = h; 93 } 94 81 95 Rectangle targetSize = ImageDisplay.calculateDrawImageRectangle( 82 new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)),96 new Rectangle(0, 0, ww, hh), 83 97 new Rectangle(0, 0, maxSize, maxSize)); 84 98 BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB); 85 99 Graphics2D g = scaledBI.createGraphics(); 86 while (!g.drawImage(img, 0, 0, targetSize.width, targetSize.height, null)) { 100 101 final AffineTransform restoreOrientation = ExifReader.getRestoreOrientationTransform(entry.getExifOrientation(), w, h); 102 final AffineTransform scale = AffineTransform.getScaleInstance((double) targetSize.width / ww, (double) targetSize.height / hh); 103 scale.concatenate(restoreOrientation); 104 105 while (!g.drawImage(img, scale, null)) { 87 106 try { 88 107 Thread.sleep(10); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
r7937 r7956 188 188 s.append(listKeys(Projections.nadgrids)+"<br>"); 189 189 s.append("<b>+bounds=</b>minlon,minlat,maxlon,maxlat - <i>"+tr("Projection bounds (in degrees)")+"</i><br>"); 190 s.append("<b>+wmssrs=</b>EPSG:123456 - <i>"+tr(" WMS SRS (EPSG code)")+"</i><br>");190 s.append("<b>+wmssrs=</b>EPSG:123456 - <i>"+tr("Sets the SRS=... parameter in the WMS request")+"</i><br>"); 191 191 192 192 return new HtmlPanel(s.toString()); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r7434 r7956 1084 1084 } 1085 1085 } 1086 return;1087 1086 } 1088 1087 -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r7864 r7956 21 21 import com.drew.metadata.exif.ExifSubIFDDirectory; 22 22 import com.drew.metadata.exif.GpsDirectory; 23 import java.awt.geom.AffineTransform; 23 24 24 25 /** … … 188 189 return value; 189 190 } 191 192 /** 193 * Returns a Transform that fixes the image orientation. 194 * 195 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 196 * as 1. 197 * @param orientation the exif-orientation of the image 198 * @param width the original width of the image 199 * @param height the original height of the image 200 * @return a transform that rotates the image, so it is upright 201 */ 202 public static AffineTransform getRestoreOrientationTransform(final int orientation, final int width, final int height) { 203 final int q; 204 final double ax, ay; 205 switch (orientation) { 206 case 8: 207 q = -1; 208 ax = width / 2; 209 ay = width / 2; 210 break; 211 case 3: 212 q = 2; 213 ax = width / 2; 214 ay = height / 2; 215 break; 216 case 6: 217 q = 1; 218 ax = height / 2; 219 ay = height / 2; 220 break; 221 default: 222 q = 0; 223 ax = 0; 224 ay = 0; 225 } 226 return AffineTransform.getQuadrantRotateInstance(q, ax, ay); 227 } 228 229 /** 230 * Check, if the given orientation switches width and height of the image. 231 * E.g. 90 degree rotation 232 * 233 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 234 * as 1. 235 * @param orientation the exif-orientation of the image 236 * @return true, if it switches width and height 237 */ 238 public static boolean orientationSwitchesDimensions(int orientation) { 239 return orientation == 6 || orientation == 8; 240 } 241 242 /** 243 * Check, if the given orientation requires any correction to the image. 244 * 245 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 246 * as 1. 247 * @param orientation the exif-orientation of the image 248 * @return true, unless the orientation value is 1 or unsupported. 249 */ 250 public static boolean orientationNeedsCorrection(int orientation) { 251 return orientation == 3 || orientation == 6 || orientation == 8; 252 } 190 253 }
Note:
See TracChangeset
for help on using the changeset viewer.