Bug 129342 - EMF+ Images with textured brushes are not drawn
Summary: EMF+ Images with textured brushes are not drawn
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Bartosz
URL:
Whiteboard: target:6.5.0 target:26.8.0 target:26.2.2
Keywords: filter:emf
Depends on:
Blocks: emf-testbed EMF-WMF 170985
  Show dependency treegraph
 
Reported: 2019-12-12 13:06 UTC by Chris Sherlock
Modified: 2026-03-02 19:37 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
test_libuemf_p_ref.emf test image from the libUEMF project (196.89 KB, image/x-emf)
2019-12-12 13:09 UTC, Chris Sherlock
Details
How test_libuemf_p_ref.emf should display (646.56 KB, image/png)
2019-12-12 13:09 UTC, Chris Sherlock
Details
How test_libuemf_p_ref.emf displays (192.27 KB, image/png)
2019-12-12 13:10 UTC, Chris Sherlock
Details
EMF+ file with textured brush (233.46 KB, image/x-emf)
2019-12-23 20:01 UTC, Bartosz
Details
EMF+ file with textured brush exported by Paint (89.41 KB, image/png)
2019-12-23 20:03 UTC, Bartosz
Details
EMF+ Tile images (80.53 KB, image/emf)
2019-12-23 21:28 UTC, Bartosz
Details
EMF+ Textured ellipse (762.07 KB, image/emf)
2019-12-23 21:42 UTC, Bartosz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Sherlock 2019-12-12 13:06:52 UTC
Description:
We are not drawing images that are embedded in EMF+ brushes. See for example the testbed EMF+ file from the libUEMF project - halfway down there are a row of rectangles that contain images. None of these display the images in Libreoffice. 

Steps to Reproduce:
Open the file test_libuemf_p_ref.emf in LibreOffice


Actual Results:
The middle row of images show in a solid colour.

Expected Results:
The solid colors should actually show patterned images. 


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Chris Sherlock 2019-12-12 13:09:05 UTC
Created attachment 156509 [details]
test_libuemf_p_ref.emf test image from the libUEMF project
Comment 2 Chris Sherlock 2019-12-12 13:09:53 UTC
Created attachment 156510 [details]
How test_libuemf_p_ref.emf should display
Comment 3 Chris Sherlock 2019-12-12 13:10:27 UTC
Created attachment 156511 [details]
How test_libuemf_p_ref.emf displays
Comment 4 Chris Sherlock 2019-12-12 14:10:56 UTC
I've currently got a number of patches queued up in gerrit around EMF+. The first thing we need to do before we can implement drawing the images is to actually read in the image. I have pushed the following gerrit patch:

https://gerrit.libreoffice.org/#/c/85054/

This needs to be reviewed. From here we can figure out what needs to paint the images in the brushes.
Comment 5 Chris Sherlock 2019-12-14 16:07:33 UTC
Whilst I am reading in EMFPImage objects with the below fix, there is a larger issue at hand. We are currently not reading in uncompressed bitmap data in EMFPImage::Read()

The code currently reads that if the bitmap type is 0x0 then it considers this to be a "non native format", when in fact the spec for EMFPlusBitmap relies on the enumeration in "2.1.1.2 BitmapDataType Enumeration". There are two types of bitmap - one that is compressed, the other that is not compressed (0x0). 

If we hit uncompressed data, then we need to read in an EmfPlusBitmapData object, specified in "2.2.2.3 EmfPlusBitmapData Object" of [MS-EMFPLUS].
Comment 6 Chris Sherlock 2019-12-17 10:32:15 UTC
So here is where I am up to. My first task was to find the code that reads in the EMFPImage. This was difficult because you can’t pass an SvMemoeyStream to a SvStream. after puzzling this out, I realised you read in a byte stream the size of the record from SvStream and then construct the SvMemoeyStream from this.

Then I checked the bitmap I read, and I realised it wasn’t reading in anything... so I checked the function that reads in the bitmap data. That’s when I realised we read compressed bitmaps, but not uncompressed DIBs. Fine. But how to read the data? We have ReadDIB functions, so I tried to read in the raw data and ignore the v5 header. This will simply not fly with the current VCL functionality. To get this working I have had to check if palette entries are being used, setup a manual v5 DIB and I then inject this into the DIB read function. 

So far so good. But then I found we don’t handle the 16bpp scanline formats. These esoteric formats were removed some time ago, and in fact two of the formats (the RGB565 ARGB1555 formats) weren’t implemented anyway. So I had to implement a conversion for these scanline formats into either 24 or 32 bpp scanline formats.

So the current state is... I have read in the graphic now, but for some reason i now can actually draw the bitmap.

I shall persevere!
Comment 7 Bartosz 2019-12-23 20:01:50 UTC
Created attachment 156760 [details]
EMF+ file with textured brush

This is minimal EMF+ file with textured brush usage.
It could be used for testing purposes.
@Chris Please let me know if you will need something special
Comment 8 Bartosz 2019-12-23 20:03:41 UTC
Created attachment 156761 [details]
EMF+ file with textured brush exported by Paint
Comment 9 Bartosz 2019-12-23 21:28:07 UTC
Created attachment 156762 [details]
EMF+ Tile images
Comment 10 Bartosz 2019-12-23 21:42:50 UTC
Created attachment 156764 [details]
EMF+ Textured ellipse
Comment 11 Bartosz 2019-12-23 21:48:49 UTC
If you will needs some specific example image just let me know.
A lot of examples to generate EMF+ image, could be found there:
https://docs.microsoft.com/pl-pl/windows/win32/gdiplus/-gdiplus-filling-a-shape-with-an-image-texture-use
Comment 12 Chris Sherlock 2019-12-29 16:38:56 UTC
Awesome! Thanks, I'll get started on this in the new year :-)
Comment 13 Chris Sherlock 2019-12-30 12:58:13 UTC
@Bartosz - the tiled one - is that tiled as in tesselated?
Comment 14 Chris Sherlock 2019-12-30 17:53:24 UTC
My code only processes uncompressed data. This brush is using compressed data.
Comment 15 Chris Sherlock 2020-01-01 15:01:27 UTC
Oh... the way we are handling multipart objects is the cause of this issue. 

This is going to require some deep work...
Comment 16 Chris Sherlock 2020-01-02 17:37:02 UTC
Scratch that last comment. This is getting quite hard to track down.
Comment 17 Xisco Faulí 2020-07-22 15:23:58 UTC Comment hidden (obsolete)
Comment 18 QA Administrators 2022-07-23 03:46:45 UTC Comment hidden (obsolete)
Comment 19 QA Administrators 2024-07-23 03:14:50 UTC Comment hidden (obsolete)
Comment 20 Commit Notification 2026-02-28 07:05:44 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6c05a6339c27038b14d2f35f8f4b2b94335d6491

tdf#129342 tdf#170985 EMF+ Implement BrushTypeTextureFill for bitmaps

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 21 Commit Notification 2026-03-02 19:37:17 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/71b257e4faf940a300753ba3fb8156271d51f9b0

tdf#129342 tdf#170985 EMF+ Implement BrushTypeTextureFill for bitmaps

It will be available in 26.2.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.