@@ -99,6 +99,22 @@ public ImageData getImageData(int zoom) {
9999 return URLImageDescriptor .getImageData (url , zoom );
100100 }
101101
102+ @ Override
103+ public ImageData getCustomizedImageData (int zoom , int flag ) {
104+ return URLImageDescriptor .getCustomizedImageData (url , zoom , flag );
105+ }
106+
107+ @ Override
108+ public boolean supportsRasterizationFlag (int flag ) {
109+ boolean supportsFlag = flag == SWT .IMAGE_DISABLE || flag == SWT .IMAGE_GRAY || flag == SWT .IMAGE_COPY ;
110+ URL tempURL = getURL (url );
111+ if (tempURL != null ) {
112+ if (tempURL .toString ().endsWith (".svg" ) && supportsFlag ) { //$NON-NLS-1$
113+ return true ;
114+ }
115+ }
116+ return false ;
117+ }
102118 }
103119
104120 private static long cumulativeTime ;
@@ -143,14 +159,14 @@ private static ImageData getImageData(String url, int zoom) {
143159 URL tempURL = getURL (url );
144160 if (tempURL != null ) {
145161 if (tempURL .toString ().endsWith (".svg" )) { //$NON-NLS-1$
146- return getImageData (tempURL , zoom );
162+ return getImageData (tempURL , zoom , SWT . IMAGE_COPY );
147163 }
148164 if (zoom == 100 ) {
149- return getImageData (tempURL , zoom );
165+ return getImageData (tempURL );
150166 }
151167 URL xUrl = getxURL (tempURL , zoom );
152168 if (xUrl != null ) {
153- ImageData xdata = getImageData (xUrl , zoom );
169+ ImageData xdata = getImageData (xUrl );
154170 if (xdata != null ) {
155171 return xdata ;
156172 }
@@ -159,22 +175,35 @@ private static ImageData getImageData(String url, int zoom) {
159175 if (xpath != null ) {
160176 URL xPathUrl = getURL (xpath );
161177 if (xPathUrl != null ) {
162- return getImageData (xPathUrl , zoom );
178+ return getImageData (xPathUrl );
163179 }
164180 }
165181 }
166182 return null ;
167183 }
168184
169185 private static ImageData getImageData (URL url ) {
170- return getImageData (url , 0 );
186+ ImageData result = null ;
187+ try (InputStream in = getStream (url )) {
188+ if (in != null ) {
189+ result = new ImageData (in );
190+ }
191+ } catch (SWTException e ) {
192+ if (e .code != SWT .ERROR_INVALID_IMAGE ) {
193+ throw e ;
194+ // fall through otherwise
195+ }
196+ } catch (IOException e ) {
197+ Policy .getLog ().log (new Status (IStatus .ERROR , Policy .JFACE , e .getLocalizedMessage (), e ));
198+ }
199+ return result ;
171200 }
172201
173- private static ImageData getImageData (URL url , int zoom ) {
202+ private static ImageData getImageData (URL url , int zoom , int flag ) {
174203 ImageData result = null ;
175204 try (InputStream in = getStream (url )) {
176205 if (in != null ) {
177- result = new ImageData (in , zoom );
206+ result = new ImageData (in , zoom , flag );
178207 }
179208 } catch (SWTException e ) {
180209 if (e .code != SWT .ERROR_INVALID_IMAGE ) {
@@ -187,6 +216,11 @@ private static ImageData getImageData(URL url, int zoom) {
187216 return result ;
188217 }
189218
219+ private static ImageData getCustomizedImageData (String url , int zoom , int flag ) {
220+ URL tempURL = getURL (url );
221+ return getImageData (tempURL , zoom , flag );
222+ }
223+
190224 /**
191225 * Returns a stream on the image contents. Returns null if a stream could
192226 * not be opened.
0 commit comments