Použití miniaturních obrazových dat

Existuje možnost zapsat obrazová data pro exportovanou entitu Vault do DI - EcENTITY.thumbnail. Chcete-li obrázek uložit na disk, nahrajte hodnotu sql jako pole bajtů a tato data zapište jako soubor jpg.

Chcete-li získat objekt .NET FRAMEWORK System.Drawing.Image, můžete použít tuto ukázku:

/// <summary>
/// http://justonesandzeros.typepad.com/blog/2011/05/viewing-thumbnails.html
/// </summary>
/// <param name="propVal">the value of the property Thumbnail</param>
/// <param name="width">image width</param>
/// <param name="height">image height</param>
/// <returns></returns>
public static System.Drawing.Image GetThumbnail(object propVal, int width, int height)
{
    if (propVal == null || false == (propVal is byte[]))
        return null;
    byte[] thumbnailRaw = (byte[])propVal;
    System.Drawing.Image retVal = null;
    using (System.IO.MemoryStream ms = new System.IO.MemoryStream(thumbnailRaw))
    {
        try
        {
            ms.Seek(12, System.IO.SeekOrigin.Begin);
            System.Drawing.Imaging.Metafile metafile =
                    new System.Drawing.Imaging.Metafile(ms);
            retVal = metafile.GetThumbnailImage(width, height,
                    new System.Drawing.Image.GetThumbnailImageAbort(GetThumbnailImageAbort),
                    System.IntPtr.Zero);
        }
        catch
        {
            retVal = null;
        }
        
        if (retVal == null)
        {
            try
            {
                ms.Seek(0, System.IO.SeekOrigin.Begin);
                System.Drawing.Image rawImage = System.Drawing.Image.FromStream(ms, true);
                retVal = rawImage.GetThumbnailImage(width, height,
                    new System.Drawing.Image.GetThumbnailImageAbort(GetThumbnailImageAbort),
                    System.IntPtr.Zero);
            }
            catch
            {
                retVal = null;
            }
        }
    }
    return retVal;
}

Last updated