-
Notifications
You must be signed in to change notification settings - Fork 184
[MacOS] Support loading and drawing images at desired size #2619
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
base: master
Are you sure you want to change the base?
[MacOS] Support loading and drawing images at desired size #2619
Conversation
4bfac54
to
f610cc6
Compare
f610cc6
to
c26d738
Compare
}); | ||
} | ||
|
||
@FunctionalInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name does not make sense as it does not consume a handle , but an image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I just removed the interface as it's only an image consumer.
c26d738
to
adff2de
Compare
return Optional.empty(); | ||
} | ||
Image image = new Image(device, imageData.get()); | ||
NSBitmapImageRep representation = image.getRepresentation(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt the image.getRepresentation be inside the if condition? also not very clear to me why do we get and remove representation at 100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be inside the if block. I fixed that with the latest commit.
We create the image based on image data in the line before (1881), which effectively creates an image with a 100% representation (out of the given image data). For that reason, we retrieve the representation at that same zoom. We then use the createRepFromSourceAndApplyFlag
to apply the style flag on that representation (which adds another representation with that styling to the image), so that we need to remove the original (unstyled) representation afterwards.
adff2de
to
2b33ae5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes LGTM
With the support of SVGs and the addition of the ImageDataAtSizeProvider, it is possible for many Image instances to provide a handle that represents the image at sharply rendered specific size in addition to the existing support of providing an image at different zooms of a base size. This change adds according support to the MacOS implementations of GC and Image. The GC#drawImage() method accepting only destination position and size now makes use of enhanced Image capabilities to load the image at the desired size if possible instead of just using the best fitting zoomed handle.
2b33ae5
to
6af993c
Compare
With the support of SVGs and the addition of the ImageDataAtSizeProvider, it is possible for many Image instances to provide a handle that represents the image at sharply rendered specific size in addition to the existing support of providing an image at different zooms of a base size.
This change adds according support to the MacOS implementations of GC and Image. The GC#drawImage() method accepting only destination position and size now makes use of enhanced Image capabilities to load the image at the desired size if possible instead of just using the best fitting zoomed handle.
Can be tested with the snippets provided for the Windows implementation PR: