Skip to main content

ImageValueConverter Class

A Value Converter which can be used to convert Image objects to an array of bytes.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v21.2.dll

Declaration

public class ImageValueConverter :
    ValueConverter

Remarks

The following example shows how to convert the value of the Image property to an array of bytes when saving it in a data store.

using DevExpress.Xpo;

public class SampleImageClass : XPObject {
    private System.Drawing.Image image;
    public SampleImageClass(Session session) : base(session) {}

    [ValueConverter(typeof(DevExpress.Xpo.Metadata.ImageValueConverter))]
    public System.Drawing.Image Image {
        get { return image; }
        set {
            SetPropertyValue(nameof(Image) , ref image, value);
        }
    }
}

ImageValueConverter requires System.Drawing.Common 5.0+. In Xamarin/Mono projects, change your image property type from System.Drawing.Image to byte[].

using DevExpress.Xpo;

[Delayed]
public byte[] Image {
    get { return GetDelayedPropertyValue(nameof(Image)); }
    set { SetDelayedPropertyValue<byte[]>(nameof(Image), value); }
}

Note

To run your application on Linux and macOS, install libgdiplus.

Ubuntu: sudo apt-get update -y && sudo apt-get install -y libgdiplus.

macOS: brew install mono-libgdiplus.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ImageValueConverter class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
ValueConverter
ImageValueConverter
See Also