Skip to main content

Search

Search

Passing Image Data To Picture Field

Comments

1 comment

  • Avatar
    Shotaro Ito

    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

Please sign in to leave a comment.