Skip to content

Commit e62052f

Browse files
arunjose696fedejeanne
authored andcommitted
Add N&N entry
New API: GC#drawImage(Image image, int destX, int destY, int destWidth, int destHeight)
1 parent 8d83f0e commit e62052f

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

news/4.38/platform_isv.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@ A special thanks to everyone who [contributed to Eclipse-Platform](acknowledgeme
77
## Platform Changes
88
-->
99

10-
<!--
11-
---
1210
## SWT Changes
13-
-->
11+
12+
### New API: `GC#drawImage(Image image, int destX, int destY, int destWidth, int destHeight)`
13+
14+
#### Description
15+
A new `drawImage` method in `GC` allows drawing the **full image** into a specified destination rectangle.
16+
Until now, the existing method
17+
`drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight)`
18+
was used for this purpose by specifying the full source bounds. The new method simplifies the process by eliminating the need to provide the actual image bounds when drawing the entire image.
19+
20+
#### New vs. Existing Method
21+
- **Existing method:** Handles scaling and cropping; requires explicit source bounds. Best suited for drawing a cropped part of the image. However, this is not a very common use case in Eclipse products, as images are mostly drawn at their full sizes.
22+
- **New method:** Handles scaling and drawing the full image more efficently, as consumers do not need to call `getBounds()` to calculate the image size. Recommended for scenarios where cropping is unnecessary.
23+
24+
#### Examples
25+
```java
26+
// Old method: requires source bounds
27+
gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height, 0, 0, 200, 100);
28+
29+
// New method: simpler, only need to provide destination cordinates
30+
gc.drawImage(image, 0, 0, 200, 100);
31+
```
32+
33+
#### Additional Note
34+
When using the new `drawImage` method, images that can provide size-specific data (such as SVGs or images backed by `ImageDataAtSizeProvider`) are loaded at the destination size, avoiding blurry scaling.
35+
For all other images the behavior remains the same as before _i.e._ they are loaded at the closest available zoom level.
36+
This destination-size loading is currently only available in the new method but may be added to the existing method in the future.

0 commit comments

Comments
 (0)