Passing Image Data To Picture Field
I'm needing to pass the actual binary image data to the label format via the SDK. Has anyone done this? If so do you have some sample code example? I have the image data in binary and in an array, but I get an error if I attempt to pass to a named substring.
Thanks
Rick B
0
-
Shotaro Ito
★ BarTender Hero ★
Hi RickBen,
On BarTender, create a Picture object as Base64 data source, then give a sharename (ex. BASE64PIC) to the data source.
From BarTender, encode binary data of a picture file (PNG, JPG, SVG etc) to base64 string.
Then, set the string to the named data source.
//c# - set base64 data source btFmt = btApp.Documents.Open(@"c:\BinaryPicSDKTest.btw"); string b64pic = ""; using (System.IO.FileStream fileStream = new System.IO.FileStream(@"c:\pic.png", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { byte[] loadData = new byte[fileStream.Length]; fileStream.Read(loadData, 0, loadData.Length); b64pic = Convert.ToBase64String(loadData); } btFmt.SubStrings["BASE64PIC"].Value = b64pic;as I understand, .net sdk can only take string data.
Since encode / decode of base64 is fairly quick, it won't be a big detour.
0
请先登录再写评论。
评论
1 条评论