VintaSoft Imaging .NET SDK and Plug-ins Discussions

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

saving a vintasoft image to a database table



saving a vintasoft image to a database table

Post by BillG »

i have a sql server database table named MemberPhotos. It has a field with a type of varbinary(MAX). Can I save a VintasoftImage to it or do I have to convert it to something else first?

Bill


Re: saving a vintasoft image to a database table

Post by Alex »

Hello Bill,

You need save image as a file to a MemoryStream object, get byte array from MemoreStream object and save byte array to a field of database table. Here is an example:
byte[] GetVintasoftImageAsByteArray(VintasoftImage image)
{
    using (MemoryStream mem = new MemoryStream())
    {
        image.Save(mem, new JpegEncoder());
        
        byte[] byteArray = new byte[mem.Length];
        mem.Position = 0;
        mem.Read(byteArray, 0, mem.Length);

        return byteArray;
    }
}
Best regards, Alexander


Page 1 from 1: 1