Issue 121504 - Data exchange of bitmaps using the clipboard does not preserve existing transparency
Summary: Data exchange of bitmaps using the clipboard does not preserve existing trans...
Status: CLOSED FIXED
Alias: None
Product: Draw
Classification: Application
Component: editing (show other issues)
Version: 4.0.0-dev
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.0.0
Assignee: Armin Le Grand
QA Contact:
URL:
Keywords:
: 115246 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-12-18 17:34 UTC by Armin Le Grand
Modified: 2022-10-28 12:54 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Armin Le Grand 2012-12-18 17:34:42 UTC
ALG: When copy/pasting a bitmap object with transparency between AOO and other applications (Gimp, paint.NET, MyPaint) the transparency information is lost in transfer. It would be much more useful if this would be preserved.
To reproduce: Create an ellipse in draw/impress, convert to bitmap -> creates bitmap with mask/fully transparent parts. CTRL+C, paste somewhere else (but at least something that is capable of working with alpha) -> background gets white or system's app background color.
Also: Add transparency gradient to ellipse, same effect.
Same is true when pasting images with transparency/masking to AOO.
This is working when saving as e.g. png and loading in AOO or vice versa.
OS is not clear yet (may be all, needs checking)
Comment 1 Armin Le Grand 2012-12-18 17:35:26 UTC
ALG: Investigating on Windows what is going on here in the background and with the clipboard...
Comment 2 Armin Le Grand 2012-12-19 09:43:51 UTC
ALG: First needed to figure out how DIBs (used in clipboard formats 'Bitmap' and 'CF_DIB' are used and created. The operator<< and >> of Bitmap use Bitmam::Read/Write (using default parameters for header and compression), which do the DIB read/write stuff using quite some impl helper methods. This means that despite the view places where DIB (DeviceIndependentBitmap) is really used, all places which stream bitmaps use DIBs without need. It should only be necessary in clipboard usage and evtl. Windows emf/wmf formats.
The clipboard cannot use transparency since the CF_DIBV5 which allows this is not supported. This needs an extansion of the DIB read/write and allows adding the alpha channel.
This collides with operator<< and >> of BitmapEx which streams the basic bitmap, then adds two magic numbers and also stream an evtl. existing alpha channel/mask *also* using DIB for this 2nd bitmap (streaming in reads ahead to check the magic numbers, then evtl. imports alpha as DIB).
Thus, when supporting CF_DIBV5 in the standard Bitmap/BitmapEx streaming operators alpha would be added double. Thus, extension of this is not straightforward.
First step is to isolate the stream operators, the DIB tooling (currently members of Bitmap) to see where and when this is used. Then check if it is possible to use DIB only for cases where it is used and extend these cases.
Comment 3 Armin Le Grand 2012-12-20 16:35:55 UTC
ALG: Removed all operator<< and operator>> from Bitmap and BitmapEx, isolated DIB tooling to own file, added own methods, replaced in whole office to make clear what happens. Added code to support not only CF_DIB but CF_DIBV5 which is capable of transparencies. Changed GetBitmap/SetBitmap in TransferableDataHelper to BitmapEx. Complete rebuild, corrections. Checking with Paint.NET, Gimp, MyPaint and Paint.
Exchange between mentioned programs is not too good either, but with the changes I can exchange transparency from AOO to Gimp and Paint.NET. Back does not work, they do not support CF_DIBV5. Looking for an app which supports that.
With a clipboard tool I can see that these apps provide 'PNG' as clipboard type; it's not an official type but seems to work using mimetype. Checking that, too.
Comment 4 Armin Le Grand 2012-12-21 16:31:50 UTC
ALG: Getting forward with adding PNG support...
Comment 5 Armin Le Grand 2013-01-03 13:09:04 UTC
ALG: Hard struggle, extra stuff for Writer's own GraphicObject; much trouble with save/load bitmaps in general. Getting closer, preparing other systems. Also played around with many scenarios, fixed stuff (assertions are helpful, btw). Continuing...
Comment 6 Armin Le Grand 2013-01-03 15:59:02 UTC
ALG: Found that there are still places where operator<< is used with BitmapEx which compile. This seems to be because Wallpaper has an implicit constructor using BitmapEx and stream operators. Argh! Implicit conversion is a baaaad thing...
Comment 7 Armin Le Grand 2013-01-04 16:58:42 UTC
ALG: Created branch https://svn.apache.org/repos/asf/openoffice/branches/alg/clibboard to work on this on multiple systems easier (yes there is a typo, so what ;-))
Comment 8 Armin Le Grand 2013-01-07 09:37:05 UTC
ALG: Win version working, going on with linux version...
Comment 9 Armin Le Grand 2013-01-07 11:46:49 UTC
ALG: Linux version built and checked, works well. Alpha is exchanged e.g. with gimp without problems. Doing some more tests...
Comment 10 Armin Le Grand 2013-01-07 13:51:38 UTC
ALG: There is one effect when insereting alpha-based graphics to writer as writer graphic object and scaling it; sometimes it gets corrupted, but only the visualisaion. Checking if this is reproducable on win version...
Comment 11 Armin Le Grand 2013-01-07 13:57:59 UTC
ALG: Could reproduce, indeed in the file the image is corrupted. Debugging...
Comment 12 Armin Le Grand 2013-01-07 18:39:56 UTC
ALG: Found a problem with ReadDIBBitmapEx/WriteDIBBitmapEx, checking necessities...
Comment 13 SVN Robot 2013-01-08 09:57:15 UTC
"alg" committed SVN revision 1430196 into branches/alg/clibboard:
#121504# corrected BitmapEx DIB exchange
Comment 14 Armin Le Grand 2013-01-08 10:03:06 UTC
ALG: Problem found; there was an error in the Header size which got written, this shifted the color palette at read time and thus made the gray palette not recognizable. Thus, the alpha channel was changed to a simple mask
Comment 15 Armin Le Grand 2013-01-09 17:48:58 UTC
ALG: Some corrections in sot and svtools for Windows, working on mac exchange...
Comment 16 Armin Le Grand 2013-01-09 17:49:26 UTC
ALG: Checked WriteDIBBitmapEx/ReadDIBBitmapEx usages...
Comment 17 SVN Robot 2013-01-09 21:31:11 UTC
"alg" committed SVN revision 1430974 into branches/alg/clibboard:
#121504# corrections, mainly for win version
Comment 18 SVN Robot 2013-01-10 09:45:17 UTC
"hdu" committed SVN revision 1431234 into branches/alg/clibboard:
add OSX clipboard support for transparent bitmaps
Comment 19 Armin Le Grand 2013-01-10 11:57:11 UTC
ALG: Herbert took care of mac adaptions beyond my changes. Checked on all three major plattforms. Preparing reintegration...
Comment 20 hdu@apache.org 2013-01-10 12:43:42 UTC
*** Issue 115246 has been marked as a duplicate of this issue. ***
Comment 21 Armin Le Grand 2013-01-10 16:21:28 UTC
ALG: Checked Mac, Linux and Win versions, works well. Preparing reintegration...
Comment 22 SVN Robot 2013-01-10 17:28:40 UTC
"alg" committed SVN revision 1431512 into trunk:
#121504# Support for alpha channel in clipboard for all systems
Comment 23 Armin Le Grand 2013-01-11 09:06:25 UTC
ALG: Reintegrated, done.
Comment 24 SVN Robot 2013-01-16 10:09:43 UTC
"alg" committed SVN revision 1433875 into trunk:
#121504# corrected error in canvas module when cairo is used