-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Describe the bug
Under some cirumstances saving an image under Linux through org.eclipse.swt.graphics.ImageLoader will distort the image.
To Reproduce
Create an image with a width that is not a multiple of the scanLinePad, e.g.
new ImageData(326, 224, 8, palette); (using the default scanLinePad of 4).
Fill this image with some drawings.
Save the image using ImageLoader.save()
Expected behavior
When the saved image is opened with a viewer, the image appears distorted.
** Diagnosis **
The class org.eclipse.swt.internal.NativeImageLoader ignores padding bytes in the source image.
Lines 316-317 and lines 331-332 should read
for (int y = 0, new_offset = 0, alphaIndex = 0; y < height; y++) {
for (int x = 0, offset=y*imgData.bytesPerLine; x < width; x++, offset += n_channels, new_offset += bytes_per_pixel) {
instead of
for (int y = 0, offset = 0, new_offset = 0, alphaIndex = 0; y < height; y++) {
for (int x = 0; x < width; x++, offset += n_channels, new_offset += bytes_per_pixel) {
Environment:
- Select the platform(s) on which the behavior is seen:
-
- [] All OS
-
- Windows
-
- [ x] Linux
-
- macOS
-
Additional OS info (e.g. OS version, Linux Desktop, etc)
Linux desktop, GTK 3 -
JRE/JDK version
Version since
Eclipse or SWT version since when the behavior is seen [e.g. 4.23]
Workaround (or) Additional context
Add any other context about the problem here.
Any known workarounds for the problem?