1

I am trying to write a property editor for the Dev Express ASPxImageZoom control so that I can use it in an XAF application to display an image.

The image is stored in a byte array.

I want to set the value of the control to contain the contents of a byte array.

However I cant figure out how to do this from the documentation. https://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxImageZoomtopic

Kirsten
  • 15,730
  • 41
  • 179
  • 318

1 Answers1

1

You can assign byte array to ASPxZImageZoom control. In below code, I am just reading a file and converting it to byte array but you can directly assign your byte array.

protected void Page_Load(object sender, EventArgs e)
{
    string filePath = Server.MapPath("~/Images/41LR9-Q2W-L._AC_UX500_SY400_.jpg");
    if (File.Exists(filePath))
    {
        Byte[] bytes = File.ReadAllBytes(filePath);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        ASPxImageZoom1.ImageUrl = "data:image/png;base64," + base64String;    
    }            
}

Hope help you implement in correct way. It just for reference. care to error handling for such implementation.

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
  • I get an error. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. – Kirsten Dec 18 '15 at 02:28
  • 1
    convert that byte to image by creating an method refer [this](http://stackoverflow.com/questions/17874733/converting-image-to-base64).. only reference first method code in the answer.. – Niranjan Singh Dec 18 '15 at 05:47
  • I have asked whether this can be done without a temporary file. http://stackoverflow.com/questions/34363040/is-there-any-way-to-set-a-url-string-without-creating-a-file – Kirsten Dec 18 '15 at 19:58
  • where are you creating temporary file. this image object will reside in the memory. You do not need to create temporary file on the server folders. just convert bytes to image and assign it to the control.. – Niranjan Singh Dec 18 '15 at 23:37
  • The only way to set the image for the control is to set its ImageUrl property which is a string. I cant assign an image to the control directly. – Kirsten Dec 18 '15 at 23:46
  • Yea.. this is the big issue to us.. well share that image file.. which causing problem. Then I can investigate much about this.. – Niranjan Singh Dec 19 '15 at 01:34
  • Oh, so sorry, when I investigated the particular file it was faulty. The code runs OK on my .jpg files. – Kirsten Dec 19 '15 at 04:09