Bug 484205 - Add support for ImageData comparison
Summary: Add support for ImageData comparison
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-11 07:35 EST by Niraj Modi CLA
Modified: 2018-07-10 14:13 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niraj Modi CLA 2015-12-11 07:35:20 EST
Currently ImageData equals comparison is based Object's reference based.
We need to implement equals method, which should perform actual state comparison of ImageData.

Expected API: ImageData.equals() implementation.
Comment 1 Eclipse Genie CLA 2015-12-24 03:30:36 EST
New Gerrit change created: https://git.eclipse.org/r/63259
Comment 2 Niraj Modi CLA 2015-12-24 04:44:37 EST
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/63259

Above ImageData#equals() logic leverages PaletteData meta-data information, to cover below compare scenario:
e.g. For PNG Image format, the ImageData#data information is sometimes stored as RGB or BGR color byte order.
Consider a 2px width by 2px height PNG image, which can have below color order
R(1x1)G(1x1)B(1x1) R(1x2)G(1x2)B(1x2) A(1x1)A(1x2) R(2x1)G(2x1)B(2x1) R(2x2)G(2x2)B(2x2) A(2x1)A(2x2)
or 
B(1x1)G(1x1)R(1x1) B(1x2)G(1x2)R(1x2) A(1x1)A(1x2) B(2x1)G(2x1)R(2x1) B(2x2)G(2x2)R(2x2) A(2x1)A(2x2)

Now whether it's a RGB or BGR order, this meta information is present in ImageData#PaletteData's RGB's mask/shift fields.
So using this information we can adjust the comparison of ImageData#data field and proceed with ImageData compare.

Also note ImageData#type information specified the image format(png/bmp/jpg/gif) and sometimes it's UN-specified, hence it is ignored in ImageData equals compare.
Comment 3 Niraj Modi CLA 2016-03-21 06:34:39 EDT
(In reply to Niraj Modi from comment #2)
> (In reply to Eclipse Genie from comment #1)
> > New Gerrit change created: https://git.eclipse.org/r/63259

Above patch works for Windows only.
On Linux the behavior varies for GTK2 and GTK3.
But for .gif format (IIRC as it was tested sometime back) the internal ImageData/PaletteData representation varies and PaletteData.isDirect true vs false cannot be compared.

Right now we don't have an immediate use-case for this.
Comment 4 Leo Ufimtsev CLA 2017-07-04 10:19:15 EDT
(In reply to Niraj Modi from comment #3)
> (In reply to Niraj Modi from comment #2)
> > (In reply to Eclipse Genie from comment #1)
> > > New Gerrit change created: https://git.eclipse.org/r/63259
> 
> Above patch works for Windows only.
> On Linux the behavior varies for GTK2 and GTK3.
> But for .gif format (IIRC as it was tested sometime back) the internal
> ImageData/PaletteData representation varies and PaletteData.isDirect true vs
> false cannot be compared.
> 
> Right now we don't have an immediate use-case for this.

I think it would be ok for this to work only on Gtk3. We don't care about adding new features on Gtk2.

If this works well on gtk3, we should consider merging. I would be happy to test on Gtk3.

CCing Eric, as he's been working on Colors.