Bug 113814 - Writer inserts certain images as black (Linux gen/x11 VCL backend)
Summary: Writer inserts certain images as black (Linux gen/x11 VCL backend)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
4.2 all versions
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Regressions-GraphicPrimitive2D
  Show dependency treegraph
Reported: 2017-11-14 04:09 UTC by Mikhail Ramendik
Modified: 2022-01-05 09:41 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:
Regression By:

The bitmap from description (4.84 KB, image/bmp)
2017-11-14 04:39 UTC, Mike Kaganski

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Ramendik 2017-11-14 04:09:29 UTC
I am trying to place certain images into a Writer document. Other images work fine, but with these ones I just get a black box with the image's aspect ratio. It is possible to make the image display normally using the Brightness control, but the default is black.

Sample image: http://www.ramendik.ru/pic-5-1as.bmp

These are BMP files made by an obscure conversion utility. They open fine in chrome and gwenview and gimp. Moreover. if I use imagemagick or gimp to convert to tiff or png, the problem persists!

After a conversion to JPG the images do display but JPG affects the quality. A Gimp conversion to PSD also fixes the issue, but not an ImageMagick conversion to PSD.

This happened in version on OpenSuSe Leap for me. Others in the ASk question at https://ask.libreoffice.org/en/question/137078/putting-certain-images-into-writer-results-in-image-sized-black-box/ were able to reproduce on Linux but not on Windows.

EDIT. from Help > About:

Version: Build ID: 30m0(Build:2) CPU Threads: 2; OS Version: Linux 4.4; UI Render: default; VCL: kde4; Layout Engine: new; Locale: en-IE (en_IE.UTF-8); Calc: group

The system is Linux, namely OpenSUSE Leap 42.2.

I start Writer, click the icon to create a blank new file, go to Insert>Image..., and select this image. I see the image as a black rectangle. Resulting ODT file: http://www.ramendik.ru/blankimage.odt

Steps to Reproduce:
1. Create a Writer document
2. Download the sample file http://www.ramendik.ru/pic-5-1as.bmp
3. Use the Insert > Image menu command to insert the image into the document

Actual Results:  
Black rectangle with aspect ration of the image is displayed

Expected Results:
Image is displayed

Reproducible: Always

User Profile Reset: No

OpenGL enabled: Yes

Additional Info:
Build ID: 30m0(Build:2)
CPU Threads: 2; OS Version: Linux 4.4; UI Render: default; VCL: kde4; Layout Engine: new; 
Locale: en-IE (en_IE.UTF-8); Calc: group

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Comment 1 Mike Kaganski 2017-11-14 04:39:34 UTC
Created attachment 137733 [details]
The bitmap from description

Reproducible with Version: Build ID: 1:5.4.2~rc2-0ubuntu0.16.04.1~lo2 CPU threads: 2; OS: Linux 4.4; UI render: default; VCL: gtk2; Locale: en-US (en_US.UTF-8); Calc: group

But not with Version: (x64) Build ID: 22b09f6418e8c2d508a9eaf86b2399209b0990f4 CPU threads: 4; OS: Windows 6.19; UI render: GL; Locale: ru-RU (ru_RU); Calc: CL
Comment 2 Telesto 2018-04-07 16:47:29 UTC Comment hidden (obsolete)
Comment 3 Buovjaga 2018-04-08 14:11:23 UTC
(In reply to Telesto from comment #2)
> Might be fixed in 5.4.4 or higher (see bug 113875). Please retest.

Nope, still black.
Works in 3.6, though.

Arch Linux 64-bit
Build ID: d4c0e7ef2b7f7e3cb36996bad72ac255b630beb4
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on April 8th 2018

Arch Linux 64-bit
Version (Build ID: e183d5b)
Comment 4 Xisco Faulí 2018-04-09 21:03:17 UTC
Reproduced in

Build ID: 3ea82be2ca7e1d65c718097ccc674ae98ecd98c5
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk2; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

but not in

Build ID: 3ea82be2ca7e1d65c718097ccc674ae98ecd98c5
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 5 Xisco Faulí 2018-04-09 21:14:30 UTC
Regression introduced by:

author	Armin Le Grand <alg@apache.org>	2013-10-31 14:43:21 +0000
committer	Caolán McNamara <caolanm@redhat.com>	2013-11-05 15:24:18 +0000
commit 2e5167528f7566dd9b000e50fc1610b7bf99132a (patch)
tree d3e8438457c0bb1b85ac80b2fbd485f1959d744c
parent 57c54792781cc9befe3a65a97b37fa85f89da0ae (diff)
Resolves: #i123500# unified Graphic processing to use GraphicPrimitive2D
(cherry picked from commit f5d69b2b8b002ca6905496a9d9065ef76b5641d7)

Bisected with: bibisect-42max

Adding Cc: to Armin Le Grand
Comment 6 Xisco Faulí 2020-03-27 10:33:34 UTC
Still reproducible in

Build ID: 5a94ac9eec4a63708262b2389aa2a434aa47112e
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded

@Armin, I thought you might be interested in this issue after you fixed bug 89901
Comment 7 Timur 2020-03-31 07:24:34 UTC
*** Bug 130774 has been marked as a duplicate of this bug. ***
Comment 8 Armin Le Grand 2020-03-31 16:29:46 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2020-03-31 16:32:54 UTC
(In reply to Armin Le Grand from comment #8)
> Cannot rep under Win, neither GDIPlus nor OpenGL nor Skia.
> Maybe *very* specific to some graphic backend...?

it seems it can only be reproducible in gen under linux. it works fine for me in

Versión: (x86)
Id. de compilación: 4e471d8c02c9c90f512f7f9ead8875b57fcb1ec3
Subprocs. CPU: 2; SO: Windows 6.1 Service Pack 1 Build 7601; Repres. IU: predet.; VCL: win; 
Configuración regional: es-ES (es_ES); Idioma de IU: es-ES
Calc: threaded
Comment 10 Armin Le Grand 2020-03-31 16:43:03 UTC Comment hidden (obsolete)
Comment 11 Buovjaga 2020-04-01 07:25:20 UTC
(In reply to Armin Le Grand from comment #10)
> Linux:
> - not under: gtk3
> - happens: x11
> Does someone know how to create others, e.g. VCL: gtk2/VCL: kde4...? And how
> to enable OpenGL as mentioned - cannot find that (anymore?) in my linux
> version..?
> @Xisco: Only could repro using x11 by setting 'SAL_USE_VCLPLUGIN=gen', does
> not happen using gtk3...?

You can try with kf5 which is short for KDE Frameworks 5. Gtk2 was already removed.

Tools - Options - LibreOffice - View - Use OpenGL for all rendering
Comment 12 Xisco Faulí 2020-04-01 08:59:02 UTC Comment hidden (obsolete)
Comment 13 Michael Weghorn 2020-04-01 09:39:05 UTC
(In reply to Xisco Faulí from comment #12)
> @Michael, this issue is only happening with gen, could you please give it a
> try with kf5 ?

I cannot reproduce with

Build ID: aa24771563425072c710e8c426323ed311437f13
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: kf5; 
Locale: en-US (en_GB.UTF-8); UI-Language: en-US
Calc: threaded

but can when using the gen VCL plugin instead

Build ID: aa24771563425072c710e8c426323ed311437f13
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: x11; 
Locale: en-US (en_GB.UTF-8); UI-Language: en-US
Calc: threaded

-> kf5 seems to be unaffected.
Comment 14 Armin Le Grand 2020-04-02 19:30:18 UTC
OOps- getting an exception when debugging paint of that Bitmap - in OutputDevice::DrawBitmap rBitmap.GetSizePixel() throws due to having a mxSalBmp member with a ptr, but looks bad...
Thought it's something in rendering - X11/XImage stuff, but seems to have to do with loading and X11 impl DDB/DIB stuff...
Comment 15 Armin Le Grand 2020-04-03 18:10:55 UTC
Debugged deeply into stuff I do not really know - it's all about X11SalBitmap. Good method to debug is:
- new draw
- insert image
- break at X11SalGraphicsImpl::drawBitmap in vcl/unx/generic/gdi/gdiimpl.cxx
- move the image or +/- for zoom in/out

When changing the created colors in line 571 in aNewVal (one green one black what is correct) -> all get s painted green.
That hints that the BM does only contain zeros, no pixels set.

Didi I mention: BM is a DIB bitmap 1bit depth, 2 colors, read from ReadDIBBitmapEx in vcl/source/gdi/dibtools.cxx - all that has no flaws (else would be wrong on other systems too)

Also interesting: OutputDevice::DrawBitmap calls OutputDevice::ScaleBitmap in line 165 in vcl/source/outdev/bitmap.cxx - that method *only* does scale when BM gets smaller - NO scale when growing - strange, who would've thought that for a method with that name...?

Anyways, debugged that one doe to it was being used and did something in a situation where it was getting smaller for screen paint - was wondering why it was later scaled AGAIN in X11SalBitmap::ImplDraw/ImplSalDDB::ImplDraw again (?) but I had zoomed now to a bigger BM - sigh.

Anyway - it seems as if one of these zooms (or both) somehow force all pixels to zero -> only black is used for paint. Or ImplSalDDB::ImplDraw and XCopyPlane does not work.
Note: There are quite some extra treatments in vcl/unx/generic/gdi/salbmp.cxx for '1 == GetBitCount()' - also in vcl/unx/generic/gdi/salbmp.cxx which may be related - e.g.

( 1 == nDepth ) ? XYBitmap :ZPixmap

is used which seems to directy use different mechanisms for x11 - which I do not know about...

@Xisco: If you know someone who knows x11 better at that stage, feel free to note that person - I'm not sure I can do much without investing lots of time...
Comment 16 Xisco Faulí 2020-04-06 16:25:21 UTC
@Caolán, any opinion wrt comment 15 from Armin ?
Comment 17 Caolán McNamara 2020-04-06 20:03:01 UTC
no idea off the top of my head, but removing the x11 drawing in favour of reusing same cairo based one that gtk3 and kf5 uses would be a good step IMO
Comment 18 Xisco Faulí 2020-07-22 14:58:57 UTC
Dear Armin Le Grand,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assign it back to yourself if you're still working on this.
Comment 19 Justin L 2021-03-17 09:54:15 UTC
repro 7.2+  when inserting the image from comment 1 into a new document.
SAL_USE_VCLPLUGIN=gen instdir/program/soffice

confirmed that it still works fine with VCL gtk3.
Comment 20 Armin Le Grand 2022-01-05 09:41:59 UTC
This commit was developed for another code base, and not merged by me. For complex changes like this, side-effects are to be expected; sadly I dont't have the cycles to deal with all the fallout. Un-Ccing myself for the while.