Skip to content

Inconsistent ImageData created after on-demand Image creation #276

@HeikoKlare

Description

@HeikoKlare

Since the introduction of on-demand creation of handles, the ImageData returned by getImageData() became inconsistent. Depending on whether a handle is existing or not, the image data is either created via OS functionality extracting the image data out of the handle or by loading the data from the original source directly. This leads to differences in image data returned by getImageData() depending on whether a handle is used for retrieval or not.

Tests showing the regression are pushed on this branch: https://github.com/vi-eclipse/eclipse.platform.swt/tree/image-regression-test

In particular, the regression from the on-demand creation in ImageDataProvider and ImageFileNameProvider was introduced in

and is demonstrated by this test:
https://github.com/vi-eclipse/eclipse.platform.swt/blob/aa7a5f21224cabf23d2097afd72250bde6bbb3a9/tests/org.eclipse.swt.tests/JUnit%20Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java#L1269-L1291

And the regression for the on-demand creation based on an ImageData was introduced in

and is demonstrated by this test:
https://github.com/vi-eclipse/eclipse.platform.swt/blob/aa7a5f21224cabf23d2097afd72250bde6bbb3a9/tests/org.eclipse.swt.tests/JUnit%20Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java#L1293-L1315

Actions

As discussed with @akoch-yatta, we should do the following:

  1. When retrieving ImageData for a Image an image that has no handle (yet), createa a temporary handle and return the ImageData from that handle to have consistent return values (addresses the above mentioned issue).
  2. Store this ImageData until a handle is created for it to avoid that ImageData is repeatedly loaded from the file system and transformed via temporary handle in case several accesses to the ImageData happen until an actual Image handle is created.

Metadata

Metadata

Assignees

Labels

HiDPIA HiDPI-Related Issue or FeatureSWTIssue for SWTregression

Type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions