Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Image for storing ImageMetadata #1496

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link
Contributor

@amartya4256 amartya4256 commented Sep 26, 2024

This PR contributes to the refactoring of Image class for win32.

The goal is to store more than just the handle of the image for each zoom level. To do that, a new private class is created (it's called ImageHandle) and an image contains one instance of this new class for each zoom level. The class contains the following fields:

  • handle
  • height
  • width

contributes to #62 and #127

Copy link
Contributor

github-actions bot commented Sep 26, 2024

Test Results

   483 files  ±0     483 suites  ±0   8m 30s ⏱️ +11s
 4 095 tests ±0   4 085 ✅ ±0   7 💤 ±0  3 ❌ ±0 
16 173 runs  ±0  16 080 ✅ ±0  90 💤 ±0  3 ❌ ±0 

For more details on these failures, see this check.

Results for commit 8f0c350. ± Comparison against base commit 5d67ce6.

♻️ This comment has been updated with latest results.

@@ -2312,6 +1979,7 @@ public void setBackground(Color color) {

/* Get the HDC for the device */
long hDC = device.internal_new_GC(null);
long handle = win32_getHandle(this, getZoom());
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, why using this handle? Shouldn't that be applied to all handles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Earlier, it was just done by the handle. But you are right. It means it was a wrong implementation already.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume your comment has been addressed, @akoch-yatta ?

The current implementation calls setBackground(Color color, long handle) for each handle in zoomLevelToImageHandle:

public void setBackground(Color color) {
	...
	zoomLevelToImageHandle.values().forEach(imageHandle -> setBackground(color, imageHandle.handle));
}

private void setBackground(Color color, long handle) {
	...
	/* Get the HDC for the device */
	long hDC = device.internal_new_GC(null);

	/* Change the background color in the image */
	BITMAP bm = new BITMAP();
	OS.GetObject(handle, BITMAP.sizeof, bm);
	long hdcMem = OS.CreateCompatibleDC(hDC);
	OS.SelectObject(hdcMem, handle);
	...
}

@amartya4256 amartya4256 force-pushed the imageMetadata branch 3 times, most recently from 8067b98 to 6225eae Compare October 10, 2024 14:29
@akoch-yatta akoch-yatta linked an issue Oct 30, 2024 that may be closed by this pull request
This contribution encapsulates the metadata of the image in an
innerclass ImageHandle which is used to create a hashmap of zoom level
to imageHandle object inside an image object, making it straight
forward to obtain any metadata information from an image for a zoom
level.

contributes to eclipse-platform#62 and eclipse-platform#127
@fedejeanne
Copy link
Contributor

Converted it back to Draft, this one should be merged in 4.35 M1

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.

Refactor Image for Multi-Zoom Support
3 participants