I have something I hope you can clarify. I'm using XPO to map to a database, and there's a blob field in there which contains image data. My XPO class is defined to use a type converter to create a System.Drawing.Image instance from the binary data, and that works great - I can see the image in the DevExpress WinForms controls, for instance.
Unfortunately, the ASPxBinaryImage doesn't show the image - instead I just get a "missing image" symbol shown. I find this very weird, because surely the ASPxBinaryImage should support images contained in System.Drawing.Image? On the other hand, I can't find any documentation that describes clearly what the supported data formats are.
To try things out, I have changed my class to deliver the byte directly, and if I bind this, it works. But I really don't want to change my class just specifically to support ASP.NET - that seems quite stupid.
I have also seen these items: http://www.devexpress.com/issue=Q274300 , http://www.devexpress.com/example=E1414 . But these don't seem to apply to me - obviously my image data is in perfect order, because otherwise I wouldn't be able to instantiate a System.Drawing.Image from the data myself. (Also, I populated the database myself, and I'm sure there's no funny OLE thing going on...)
So - please explain. What data formats is the ASPxBinaryImage supposed to work with? Is System.Drawing.Image really not supported? If it is, do you have an idea why it wouldn't work with my images? Is there some documentation somewhere that I'm missing? If not, please consider adding these details to the docs!
According to the ASPxBinaryImage Class description, a binary image displays any valid image (supported by the requesting browser) taken from a binary stream. A valid image is an image that we usually see everywhere: BMP, GIF, PNG, JPG etc. ASPxBinaryImage displays images that are stored in the ASPxBinaryImage.ContentBytes property.
The System.Drawing.Image is an abstract class that reads meta information from physical images and then can be used in many painting methods provided by .NET Framework. However, I do not see any operators allowing you to implicitly convert the Image object (an object, not an image file) to a proper array of bytes that can be supported by the browser.
For example, you can simply convert the Image object to a bitmap file and store it somewhere to use it as a valid image to display it on the page. If you take a look at the System.Drawing.Image to System.Web.UI.Webcontrols.Image forum post, you will see some additional information regarding this topic.
Well... to me, a System.Drawing.Image is nothing but a convenient wrapper around a binary stream of image data. If I handle images in my data structures, I use System.Drawing.Images for them, because they are easy to handle, create, modify, or whatever else I need to do with them.
If you want to convert these back and forth with the type byte, the .NET Framework has the standard class System.Drawing.ImageConverter which can do this for you. XPO comes with an ImageValueConverter class, which utilizes this same standard .NET class to do the conversion on the fly. As a result, my XPO classes naturally contain properties of type System.Drawing.Image, which are persisted to the database as byte.
I understand your reply to say that the ASPxBinaryImage was never intended to support any field data type apart from byte. Correct? You avoided that question patently, but I apologize for repeating it.
If my understanding is true, please take on board my suggestion to extend the behavior to add compatibility with fields of type System.Drawing.Image. The way it is right now is highly inconvenient.
Finally, I'm afraid I can't take your suggestions from your last paragraph seriously. After all, the entire reason to use the ASPxBinaryImage as opposed to the ASPxImage is that I *don't* want to deal with the process of storing the image in a file myself. I want the component to handle this step.
Thank you for your reply. It seems that in your argumentation, you do not take into account the System.Drawing namespace, which is for Windows applications (Windows Forms). According to your suggestion, you propose to allow the ASPxBinaryImage control to operate with WinForms classes.
Please open the link at MSDN to see the following warning:
Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.
That is why I told you to convert some meta object to a real image file.
> I understand your reply to say that the ASPxBinaryImage was never intended to support any field data type apart from byte. Correct? You avoided that question patently, but I apologize for repeating it.
Yes, ASPxBinaryImage uses an array of bytes to display an image. For example, you can read a physical file from a disk into memory and use it in a binary image control.