Book a Demo

Author Topic: Shape script image decorations get black backgrounds in generated documents  (Read 5284 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Hi all,


I'm on 13.5, but we'll upgrade in a few weeks.

I'm working on an MDG Technology which includes stereotypes where I use a shape script to decorate elements with images, which are included in the technology. They were imported into the MDG project as PNG, and render correctly in diagrams.

However, when I generate a document, they get black backgrounds.

Some images are monochrome black + whatever background colour is in the image, so they turn out as plain black squares.
Other images have colour. Their foreground is unaffected, but they get the black background.
Both variants render correctly in diagrams, with transparent backgrounds.

I had noticed the same problem when copy/pasting from a diagram into MS Office, but I got rid of that by switching the clipboard format to Bitmap (instead of Metafile) in the preferences. But there's no corresponding option for document generation.

There is a Renderer option in Diagram -- Appearance, but it does not seem to affect document generation, or at least, none of the renderers resolve the issue. I've tried all six.

I get the same result whether I generate DOCX or PDF. RTF also yields the same result, but takes massive amounts of time.

For a document which contains one diagram and nothing else, where the diagram has 12 connectors (information flow) and 10 elements with images and 3 without, the DOCX weighs in at 40 MB and the RTF 80. (The PDF ends up at 500 K.)

A similar document where the diagram has no decoration images comes in at 110 K. The images are 20 KB.


Clearly there's something weird going on with images in shape scripts.

Is there anything I can do to fix the images?

Or is someone able to check if this is fixed in 15?
I've found no mention in the version histories.

Or -- last ditch -- is there a way of getting a diagram image into a generated document without using DocumentGenerator.DocumentDiagram()? There's no InsertImage() in the API.


Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Ideally you would replace the image decorations with pure schapescript decorations.

If that is not an option, theoretically you should be able to use a document script fragment to get the diagram image.
This type of fragment requires to return an RTF string, so you would need to translate the image into RTF somehow.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Ideally you would replace the image decorations with pure schapescript decorations.

If that is not an option, theoretically you should be able to use a document script fragment to get the diagram image.
This type of fragment requires to return an RTF string, so you would need to translate the image into RTF somehow.
Yeah, could do. But that's a pretty serious amount of work to get around a bug which can't be that hard to fix.

Anyway, I worked it out. Use metafiles.

The underlying problem seems to be that EA screws up the transparency when using PNG. EA labels PNG images as "Bitmap" in its Image list; not sure whether it's converted on the way in or what, but the transparency is handled correctly in diagrams, and in the clipboard when using the "Bitmap" clipboard format, but not in documents.

There's also something weird going on with these "bitmaps" when deploying them in a technology. The image browser shows them correctly if the image is in the project, but if it's in a technology it's wrong.
But even those used from a technology are rendered correctly in diagrams, and even those local to the project are rendered incorrectly in documents.

If you work with EMF images it all works. This results in humongous technologies, and generated documents, but it works.
(I haven't tested with WMF.)

One minor niggle is that when PowerPoint saves an image as EMF, EA recognizes it as a "Metafile". The image library does have an "ENHMetafile" type which appears to be what EA creates when storing a diagram in the image library, but what PowerPoint creates doesn't qualify.

Oh, and using "Metafile" images also means the images are rendered correctly when copy/pasting and using the "Metafile" clipboard format.


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Nice, thanks for the research Uffe

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
I now noticed the Diagram Format option in the Generate Documentation dialog; Metafile or Bitmap.
Possibly switching this to Bitmap might make the PNG transparency work as intended.

I haven't tested that, but if anyone stumbles onto this thread in future and decides to investigate further, please add your results here.

/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
BMP doesn't have any transparency at all. Only PNG and vector graphics have that.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
BMP doesn't have any transparency at all. Only PNG and vector graphics have that.
I know, but images imported as PNG are listed in the EA image library as "Bitmap" and the options that relate to this area allow the selection of "Bitmap" or "Metafile."

Since EA does handle transparency correctly in some cases (and possibly in all cases if you switch the second option I mentioned), I assume that the "Bitmap" label in the image library is incorrectly applied to PNG and that EA knows which of the "Bitmap" images in the library have transparency and which do not.

This doesn't help with either understanding how it works, or explaining the issue to someone else. :)

/U
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Well, it's EA, isn't it? Seems they just diff between vector (EMF and the like) and not vector (anything else; determined by the magic number inside the file or maybe the file extension).

There had been lengthy discussions about transparency. I would not wonder if issues still creep around in EA's guts. Anything strange with V15? Report a bug... and good luck.

q.