Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: survex on May 08, 2015, 10:53:51 pm
-
Is there any way to add image to diagram?
The main problem is to add image to Image Manager, because I don't know how to add image to diagram without adding it to Image Manager.
Has anyone code snippet solving this problem?
-
If you copy an image you can paste it to a diagram using Ctrl-Shift-Insert
It looks like it creates a boundary with this image as appearance.
I'm sure there's a way to simulate the same using a script. (if needed by updating the database directly)
Geert
-
When you add image to diagram by pasting one new record added to t_image table like:
ImageID;Name;Type;Image;
1585110939;Image70166;Bitmap; ;
EA somehow stores image internally (no external image file) and I don't have any clue how to add image to EA.
-
I guess you somehow have to store the binary blob of the image in the t_image.Image column.
Seems like pretty standard stuff so you should be able to find something on google.
Geert
-
You need to have the image in t_image (Settings/Images or where ever the menu might be), then add a boundary to a diagram and assign it an alternate image with the id of this very image in t_image.
q.
-
That's the main trick - how to add image to t_image table?
-
Funny that similar threads appear one after the other:
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1431104354
q.
-
Ok,
I'm reading image file like:
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile("Z:\\home\\survex\\Desktop\\chart2.php.png", 1);
// Read from the file and display the results.
while (!f.AtEndOfStream)
{
var r = f.ReadLine();
Session.Output(r);
}
f.Close();
and getting byte symbols:
‰PNG
EEE[ch1041]v[ch1038][ch1083][ch1059][ch1073]M[ch1086][ch1060]…N[ch1085][ch1112][ch1063][ch1114]8q"))i[ch1040][ch1026]”d[ch1055][ch1115]=^”3p[ch1072][ch1040]„„„[ch1042][ch1042][ch1042]#...
while t_image contains image like ASCII stream:
89g8CIEkQhIjgkAQ3WCMDyQq2FpEwTYWrCJWrBAsIloQFYtN5VUf/GwNYKFiFEVRo1IqBaxE
EAOS4IOHBAhLAgkBQh6bxz5nfn9MMpmdnZmd2cw+kpzvZz9h9txz7j07ey9n5547d4isrCxA
...
How can I convert one to another to INSERT it to database?
-
I don't know how to handle this with your language. When I'm using Perl I use a DB driver that allows parameters like
INSERT INTO table (Col) VALUES (?)
and then I bind that to the blob.
t_image.image should hold the same binary data. I posted here something related how to handle it.
q.
P.S. http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1390927928/9#9
-
You should really try this (http://lmgtfy.com/?q=how+to+insert+image+in+access+database+using+sql)
Geert
-
Geert, pretty offensive comment... Google gives no answer how to add image to MS-Access via JScript.
-
Actually if you google for OLEDB JSCRIPT (after Geert's LMGTFY) you will find this: https://msdn.microsoft.com/en-us/library/aa325887(v=vs.71).aspx
q.
-
Geert, pretty offensive comment... Google gives no answer how to add image to MS-Access via JScript.
It is not meant as offensive, but as helpful; with a wink.
The reason I'm posting it is because the problem you have right now is not specific to EA, and I'm sure you can find the answer if you google a bit.
Geert
-
The current problem is:
t_image.Image is field of type bin.base64, so all data being inserted in table has base64 encode transformation:
UPDATE t_image SET Image = 'abcdabcd';
and
SELECT * FROM t_image => YWJjZGFiY2Q=
Trying to insert image byte data via JScript I'm getting following error:
DAO.Database [3075]
Syntax error in string in query expression ''‰PNG
'., Line:95
>:(
-
Looking for a way to insert base64 encoded data without MS-Access internal base64 encoding.
-
You will need binding since you can not (easily) insert blob data with a plain SQL. For the base64 encoding you'll probably find some lib as well.
q.