Bug 567887

Summary: [GTK] ImageLoader failed to save image when bytesPerLines is not multiple of image's width
Product: [Eclipse Project] Platform Reporter: Arnaud de Muyser <arnaud.demuyser>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: major    
Priority: P3    
Version: 4.24   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
screenshot of snipet displaying loaded image, same image saved & reloaded
none
original picture none

Description Arnaud de Muyser CLA 2020-10-14 14:31:53 EDT
Created attachment 284454 [details]
screenshot of snipet displaying loaded image, same image saved & reloaded

Environment:
Ubuntu 20.04.1 LTS (focal)
eclipse: 2020_09
java: openjdk version "14.0.1" 2020-04-14
(also having issue with java-8-openjdk-amd64)
swt: org.eclipse.swt_3.115.0.v20200831-1002.jar
     org.eclipse.swt.gtk.linux.x86_64_3.115.0.v20200831-1002.jar


I can load  colored images using ImageLoader.load() and display image data correctly, painting image data's on a canvas.

When I save this image data (using JPEG or PNG format), image in file appears as black & white with pixel shift at each line.

This occurs when image data's bytesPerLines = width * (depth/8) + N  with N >= 1
(often 2).  (note that ImageData.data.length = bytesPerLines * height)

Original file can be loaded & correctly displayed using gimp, system' picture viewer, pngcheck report:
OK: Andorre la Viella, série 5.png (786x560, 24-bit RGB, non-interlaced, 34.4%).

on saved PNG file, pngcheck command reports:
OK: Andorre la Viella, série 5.png (786x560, 32-bit RGB+alpha, non-interlaced, 41.1%).

on saved jpeg, file commands reports:
ndorre la Viella, série 5.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 786x560, components 3
Comment 1 Arnaud de Muyser CLA 2020-10-14 14:33:57 EDT
Created attachment 284455 [details]
original picture
Comment 2 Arnaud de Muyser CLA 2023-12-25 13:02:07 EST
Reproduced using Eclipse 4.26.0
using plugins:
org.eclipse.swt_3.122.0.v20221123-2302.jar
org.eclipse.swt.gtk.linux.x86_64_3.122.0.v20221123-2302.jar