Skip to content

Commit bebd5a1

Browse files
committed
Feature Proposal: Rasterization of SVGs at Runtime for Eclipse Icons
Fixes #1438 Eclipse currently loads icons exclusively as raster graphics (e.g., `.png`), without support for vector formats like `.svg`. A major drawback of raster graphics is their inability to scale without degrading image quality. Additionally, generating icons of different sizes requires manually rasterizing SVGs outside Eclipse, leading to unnecessary effort and many icon files. This PR introduces support for vector graphics in Eclipse, enabling SVGs to be used for icons. Existing PNG icons will continue to be loaded alongside SVGs, allowing the use of the new functionality without the need to replace all PNG files at once. --- - **How It Works**: - To use SVG icons, simply place the SVG file in the bundle and reference it in the `plugin.xml` and other necessary locations, as is done for PNGs. No additional configuration is required. - At runtime, Eclipse uses the library JSVG to rasterize the SVG into a raster image of the desired size, eliminating the need for scaling. My analysis shows that JSVG is the most suitable Java library for this purpose. - You need to write the flag `-Dswt.autoScale=quarter` into your `eclipse.ini` file or into the run arguments of a new configuration.
1 parent 336080e commit bebd5a1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ private static ImageData getImageData(String url, int zoom) {
146146
return getImageData(tempURL, zoom);
147147
}
148148
if (zoom == 100) {
149-
return getImageData(tempURL);
149+
return getImageData(tempURL, zoom);
150150
}
151151
URL xUrl = getxURL(tempURL, zoom);
152152
if (xUrl != null) {
153-
ImageData xdata = getImageData(xUrl);
153+
ImageData xdata = getImageData(xUrl, zoom);
154154
if (xdata != null) {
155155
return xdata;
156156
}
@@ -159,7 +159,7 @@ private static ImageData getImageData(String url, int zoom) {
159159
if (xpath != null) {
160160
URL xPathUrl = getURL(xpath);
161161
if (xPathUrl != null) {
162-
return getImageData(xPathUrl);
162+
return getImageData(xPathUrl, zoom);
163163
}
164164
}
165165
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WorkbenchImages.java

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ private static final void declareImages() {
236236
declareImage(ISharedImages.IMG_DEF_VIEW, PATH_EVIEW + "defaultview_misc.png", true); //$NON-NLS-1$
237237

238238
declareImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW, PATH_ELOCALTOOL + "close_view.png", true); //$NON-NLS-1$
239+
declareImage(IWorkbenchGraphicConstants.IMG_LCL_PIN_VIEW, PATH_ELOCALTOOL + "pin_view.png", true); //$NON-NLS-1$
239240
declareImage(IWorkbenchGraphicConstants.IMG_LCL_MIN_VIEW, PATH_ELOCALTOOL + "min_view.png", true); //$NON-NLS-1$
240241
declareImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU, PATH_ELOCALTOOL + "view_menu.png", true); //$NON-NLS-1$
241242
declareImage(IWorkbenchGraphicConstants.IMG_LCL_BUTTON_MENU, PATH_ELOCALTOOL + "button_menu.png", true); //$NON-NLS-1$

0 commit comments

Comments
 (0)