-
Notifications
You must be signed in to change notification settings - Fork 182
Add internal API in SVGrasterizer to rasterize images at given height and width #2514
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?
Add internal API in SVGrasterizer to rasterize images at given height and width #2514
Conversation
@arunjose696 can we please mirror the (relevant) information in the PR? Its always a bit hard to follow for others what are is discussed if it happens in another repository with a different organization. |
*/ | ||
public ImageData rasterizeSVG(InputStream stream, int zoom) throws IOException; | ||
|
||
public ImageData rasterizeSVG(InputStream stream, int width, int height) throws IOException; |
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.
Please add javadoc here, also if there are any limitations (e.g. what happens when size is negative).
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.
Added javadoc
Test Results 118 files ±0 118 suites ±0 11m 9s ⏱️ + 1m 57s For more details on these failures, see this check. Results for commit 1d8eb8c. ± Comparison against base commit 7d4190a. ♻️ This comment has been updated with latest results. |
663817f
to
c04bcdf
Compare
c04bcdf
to
a0f0f0b
Compare
@arunjose696 can you please fix the compilation errors?
|
74d2f86
to
2f57b89
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.
In general, the change looks good. I have rather minor comments.
* If {@code width} or {@code height} | ||
* is zero or negative, this method throws an {@link SWT#ERROR_INVALID_ARGUMENT}. |
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.
You could document this in a @exception
documentation for SWTException
just like for other SWT APIs (such as the Control
constructor to only mention one example). You could also add the explanation for SWT#ERROR_INVALID_IMAGE
there.
assertEquals(300, data.width); | ||
assertEquals(150, data.height); | ||
} | ||
|
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.
I was wondering if it's a good idea to tighly couple the general SWT test bundle to the current SVG fragment with one possible SVGRasterizer implementation. But I think that's better than adding some unnecessary abstraction for the test setup, as they are easy to adapt if necessary anyway.
Since you have already add tests for the new constructors, maybe you could also add similiar tests for the existing constructors and the exceptional cases (width/height < 0, invalid stream etc.)?
@@ -0,0 +1,52 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2024, 2025 Yatta Solutions and others. |
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.
* Copyright (c) 2024, 2025 Yatta Solutions and others. | |
* Copyright (c) 2025 Yatta Solutions and others. |
… and width Adding internal API to SVGRasterizer and simple tests to see if the svgs are loaded at right sizes by the rasterizer
2f57b89
to
1d8eb8c
Compare
It shall be possible to draw images at a custom zoom or size while maintaining the best achievable quality. To support this, images originating from an SVG source must be rasterized at the required size.
The internal API introduced in this PR enables loading SVGs at custom sizes, allowing images to be drawn at any requested zoom level or resolution, as discussed in in vi-eclipse/Eclipse-Platform#326
This PR specifically adds the internal API to handle rasterization for images coming from SVG sources.