- Timestamp:
- 2020-08-12T13:03:59+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r16871 r16872 34 34 import org.openstreetmap.josm.io.OnlineResource; 35 35 import org.openstreetmap.josm.spi.preferences.Config; 36 import org.openstreetmap.josm.tools.ImageProvider; 37 import org.openstreetmap.josm.tools.ImageProvider.ImageSizes; 36 38 import org.openstreetmap.josm.tools.LanguageInfo; 37 39 import org.openstreetmap.josm.tools.Logging; … … 199 201 200 202 static String fixImageLinks(String s) { 201 Matcher m = Pattern.compile("src=\"/browser/trunk/resources (/images/.*?\\.svg)\\?format=raw\"").matcher(s);203 Matcher m = Pattern.compile("src=\"/browser/trunk/resources/images/(.*?)\\.(png|svg)\\?format=raw\"").matcher(s); 202 204 StringBuffer sb = new StringBuffer(); 203 205 while (m.find()) { 204 206 String im = m.group(1); 205 URL u = GettingStarted.class.getResource(im);207 String u = new ImageProvider(im).setMaxSize(ImageSizes.HTMLINLINE).getDataURL(); 206 208 if (u != null) { 207 try { 208 m.appendReplacement(sb, Matcher.quoteReplacement("src=\"" + Utils.betterJarUrl(u, u) + '\"')); 209 } catch (IOException e) { 210 Logging.error(e); 211 } 209 m.appendReplacement(sb, Matcher.quoteReplacement("src=\"" + u + '\"')); 212 210 } 213 211 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r16838 r16872 21 21 import java.awt.image.ImageFilter; 22 22 import java.awt.image.ImageProducer; 23 import java.awt.image.RenderedImage; 23 24 import java.awt.image.RGBImageFilter; 24 25 import java.awt.image.WritableRaster; 25 26 import java.io.ByteArrayInputStream; 27 import java.io.ByteArrayOutputStream; 26 28 import java.io.File; 27 29 import java.io.IOException; … … 174 176 * @since 13369 175 177 */ 176 STATUSLINE(18, 18); 178 STATUSLINE(18, 18), 179 /** 180 * HTML inline image 181 * @since 16872 182 */ 183 HTMLINLINE(24, 24); 177 184 178 185 private final int virtualWidth; … … 663 670 else 664 671 return ir.getImageIcon(new Dimension(virtualWidth, virtualHeight), multiResolution); 672 } 673 674 /** 675 * Execute the image request and scale result. 676 * @return the requested image as data: URL or null if the request failed 677 */ 678 public String getDataURL() { 679 ImageIcon ii = get(); 680 if (ii != null) { 681 final ByteArrayOutputStream os = new ByteArrayOutputStream(); 682 try { 683 Image i = ii.getImage(); 684 if(i instanceof RenderedImage) { 685 ImageIO.write((RenderedImage)i, "png", os); 686 return "data:image/png;base64,"+Base64.getEncoder().encodeToString(os.toByteArray()); 687 } 688 } catch (final IOException ioe) { 689 return null; 690 } 691 } 692 return null; 665 693 } 666 694
Note:
See TracChangeset
for help on using the changeset viewer.