Skip to content

Introduce simple API to save ImageData to file and support '.jpg' extension#2103

Open
HannesWell wants to merge 2 commits into
eclipse-platform:masterfrom
HannesWell:add-ImageData-save
Open

Introduce simple API to save ImageData to file and support '.jpg' extension#2103
HannesWell wants to merge 2 commits into
eclipse-platform:masterfrom
HannesWell:add-ImageData-save

Conversation

@HannesWell

@HannesWell HannesWell commented May 5, 2025

Copy link
Copy Markdown
Member

Currently it's quite cumbersome to save ImageData into a file. screenshot from a Control or a Display. This proposes a convenience API to simplify this task.

This also complements the ImageData.load(Path) method introduced in

It becomes also very simple to take and save a screenshot together with

@github-actions

github-actions Bot commented May 5, 2025

Copy link
Copy Markdown
Contributor

Test Results

   545 files  + 6     545 suites  +6   29m 47s ⏱️ - 1m 1s
 4 376 tests +37   4 358 ✅ +35   18 💤 +3  0 ❌  - 1 
16 643 runs  +37  16 503 ✅ +35  140 💤 +3  0 ❌  - 1 

Results for commit b724b57. ± Comparison against base commit d1859ce.

@HannesWell HannesWell force-pushed the add-ImageData-save branch from 3627584 to 19b2b72 Compare May 5, 2025 23:24
@HannesWell HannesWell changed the title Introduce simple API to save ImageData to a file and support .jpg Introduce simple API to save ImageData to file and support jpg extension May 5, 2025
@HannesWell HannesWell changed the title Introduce simple API to save ImageData to file and support jpg extension Introduce simple API to save ImageData to file and support '.jpg' extension May 5, 2025

@laeubi laeubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we should clutter the ImageData class more can't we use ImageLoader(sic) for this that already is used internally anyways?

@HannesWell

Copy link
Copy Markdown
Member Author

Currently there are only convenience methods to load ImageData. Right now it's a constructor copying the first element of an ImageData-array into itself, but it will become just ImageData.load() with #1767. Currently there is no (simple) way to save an Image(Data) to a file. So I think this closes a gap in the Image(Data) API and I don't consider this as cluttering the API.
If we move this somewhere else then we can also just leave it as it, because many wont discover that way then anyways.

That one has to write an article about how to simply write an image to a file, is IMO an indication that the API is too complicated:
https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#Saving%20Images

Of course there are cases where one still needs an ImageLoader, but the simple cases should be simple.

@laeubi

laeubi commented May 7, 2025

Copy link
Copy Markdown
Contributor

I don't think that adding methods to ImageData is a good idea, this should only be a data carrier and is not a general purpose place to put continence methods.

So why cant this static methods live in ImageLoader (or we can have a new ImageWriter)?

@akurtakov

Copy link
Copy Markdown
Member

Would you please split the *.jpg support in its own PR so it can be merged now?

@akurtakov

Copy link
Copy Markdown
Member

Is there still interest in this one or it should be closed?

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.

3 participants