Package org.eclipse.swt.graphics
Interface ImageDataAtSizeProvider
- All Superinterfaces:
ImageDataProvider
An extension of the
ImageDataProvider that is capable of providing
image data at a specified size instead of or in addition to a specified zoom.
This requires an implementation of the getImageData(int, int) method
for providing image data at a specified size. Optionally, the
getDefaultSize() method can be overwritten such that the image data
can also be retrieved via a zoom that uses the default size as reference for
the 100% version. This serves two use cases:
- The image data source is size independent, such that the provider can
specify at what size the image data is to be provided. As an example, an SVG
image source may be defined at arbitrary size and the implementation of this
provider can define at which default size the image is to be used at 100%
zoom. To achieve this, the
getImageData(int, int)has to be implemented for the retrieval of image data at a given size andgetDefaultSize()has to be overwritten to define the default size at 100% zoom. - An image created with this data provider is to be drawn at a custom size
(and not a specific zoom). Such a drawing can be performed via
GC.drawImage(Image, int, int, int, int). For this case,getDefaultSize()does not need to be overwritten, as the zoom-based version of the image data is not of interest.
- Since:
- 3.132
- Restriction:
- This class is still experimental API and might be subject to change.
-
Method Summary
Modifier and TypeMethodDescriptiondefault PointReturns the default size of the image data returned by this provider.default ImageDatagetImageData(int zoom) Returns the image data for the given zoom level.getImageData(int width, int height) Returns theImageDatafor the given width and height.
-
Method Details
-
getImageData
Description copied from interface:ImageDataProviderReturns the image data for the given zoom level.-
If no image is available for a particular zoom level, this method should
return
null. Forzoom == 100, returningnullis not allowed, and SWT will throw an exception. -
Implementations are expected to return
ImageDatathat is linearly scaled with respect to the zoom level. For example, ifgetImageData(100)returns an image of widthwand heighth, thengetImageData(200)must return anImageDataof width2 * wand height2 * h, if a non-nullresult is returned.
- Specified by:
getImageDatain interfaceImageDataProvider- Parameters:
zoom- The zoom level in % of the standard resolution (which is 1 physical monitor pixel == 1 SWT logical point). Typically 100, 150, or 200.- Returns:
- the linearly scaled image data for the given zoom level,
or
nullifzoom != 100and no image is available for the given zoom level.
-
If no image is available for a particular zoom level, this method should
return
-
getDefaultSize
Returns the default size of the image data returned by this provider. It conforms to the size of the data that is returned when callinggetImageData(int)with a zoom value of 100. This method can also return (-1, -1), in which casegetImageData(int)will return dummy data of size (1, 1). This reduces potential overheads for the use case in which image data is only retrieved size-based viagetImageData(int, int).- Returns:
- the default size of the data returned by this provider for 100% zoom
-
getImageData
Returns theImageDatafor the given width and height.Implementation notes:
- Returning
nullis not permitted. Ifnullis returned, SWT will throw an exception when loading the image. - The returned
ImageDatamust match the requested width and height exactly. Implementations should ensure proper resizing and scaling of the image based on the height and width requested
- Returning
-