Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit d59074e

Browse files
hkielOpenModelica-Hudson
authored andcommitted
embed image data from URI into svg
Belonging to [master]: - #2695
1 parent e6854b5 commit d59074e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Examples/generate_icons.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import sys
3737
import time
3838
import hashlib
39+
import base64
3940
from optparse import OptionParser
4041

4142
import svgwrite
@@ -287,18 +288,16 @@ def getGraphicsForClass(modelicaClass):
287288
if r:
288289
g = r.groups()
289290
graphicsObj['type'] = 'Bitmap'
290-
# Bitmap(true, {0.0, 0.0}, 0, {{-98, 98}, {98, -98}}, "modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/TorusIcon.png"
291-
292291
graphicsObj['visible'] = g[0]
293292
graphicsObj['origin'] = [float(g[1]), float(g[2])]
294293
graphicsObj['rotation'] = float(g[3])
295294
graphicsObj['extent'] = [[float(g[4]), float(g[5])], [float(g[6]), float(g[7])]]
296-
print icon_line
297295
if g[9] is not None:
298296
graphicsObj['href'] = "data:image;base64,"+g[9].strip('"')
299297
else:
300-
logger.warning('Not yet supported: {0} with URL'.format(graphics['type']))
301-
graphicsObj['href'] = g[8].strip('"')
298+
fname = ask_omc('uriToFilename', g[8], parsed=False).strip().strip('"')
299+
fdata = open(fname, "rb").read()
300+
graphicsObj['href'] = "data:image;base64,"+base64.b64encode(fdata)
302301

303302
if not 'type' in graphicsObj:
304303
r = regex_any.search(icon_line)

0 commit comments

Comments
 (0)