Skip to content

Conversation

@al-noori
Copy link
Contributor

@al-noori al-noori commented Dec 26, 2025

Previously, GC#drawImage was only used in Snippet 10 to demonstrate scaling. Since the method also supports cropping parts of a source image, and scaling itself can be achieved by passing only the destination coordinates/width/height, this PR adds a more expressive snippet.

@al-noori al-noori force-pushed the al-noori/SnippetForDrawImage branch 2 times, most recently from 5a92e80 to ebd2b7b Compare December 26, 2025 11:04
@github-actions
Copy link
Contributor

github-actions bot commented Dec 26, 2025

Test Results

  176 files  ±0    176 suites  ±0   26m 20s ⏱️ + 1m 24s
4 676 tests ±0  4 654 ✅ ±0  22 💤 ±0  0 ❌ ±0 
  482 runs  ±0    476 ✅ ±0   6 💤 ±0  0 ❌ ±0 

Results for commit b887982. ± Comparison against base commit ddac0aa.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@akoch-yatta akoch-yatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good to me.
I need to test a bit more, but the Screenshot of the snippet and the entry in Snippets.md is missing, have a look e.g. in cf6ee39 to see, what is necessary for a new Snippet

@al-noori al-noori force-pushed the al-noori/SnippetForDrawImage branch from ebd2b7b to 51500ee Compare January 2, 2026 14:30
@al-noori
Copy link
Contributor Author

al-noori commented Jan 2, 2026

A preview screenshot and an entry in the snippets.md file are now included.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the name of the folder containing the images is currently "Snippet388" whereas the snippet number is 389.

@al-noori al-noori force-pushed the al-noori/SnippetForDrawImage branch 2 times, most recently from fca7ccd to 57ed4f8 Compare January 9, 2026 09:03
@HeikoKlare HeikoKlare force-pushed the al-noori/SnippetForDrawImage branch from 57ed4f8 to 843b0b6 Compare January 9, 2026 09:25
Previously, GC#drawImage was only used in Snippet 10 to demonstrate
scaling. Since the method also supports cropping parts of a source
image, and scaling itself can be achieved by passing only the
destination coordinates/width/height, this commit adds a more expressive
snippet.
@HeikoKlare HeikoKlare force-pushed the al-noori/SnippetForDrawImage branch from 843b0b6 to b887982 Compare January 9, 2026 09:36
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snippet looks fine. I would like to merge it soon as it currently kind of blocks #2926, which introduces subsequent Snippet390. @akoch-yatta do you have any concerns? In case we find some need to improve the snippet afterwards, we can still adapt.

With the latest changes, I just fixed the following:

  • Formatting of the Java file
  • Wrong path to images (still contained "Snippet388", so snippet did not start)
  • Replaced the preview image with one taken at 100% monitor zoom as the previous one was too large for the SnippetExplorer
  • Removed faulty issue reference from commit message

@akoch-yatta
Copy link
Contributor

I'm fine with merging it, my original remarks were solved

@HeikoKlare HeikoKlare merged commit bbb21e5 into eclipse-platform:master Jan 9, 2026
23 checks passed
@HeikoKlare HeikoKlare deleted the al-noori/SnippetForDrawImage branch January 9, 2026 10:11
@HeikoKlare
Copy link
Contributor

Adding the snippet to the SWT website via:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make a Snippet for Cropping + Scaling of GC#drawImage

4 participants