My source images are stored in server file system. I need to get the image and treak them on client side. So, I tried to use AspxBinaryImage controls. To get the image data, I need to
1. OPEN image files to a FileStream: FileStream fs = new FileStream(@"c:\file.jpg", FileMode.Open); and
2. READ FileStream to an Array Byte: fs.Read(ImageData,0,System.Convert.ToInt32(fs.Length)); and
3. SET: AspxBinaryImage.ContentBytes=ImageData;
Is this a correct way to load image data from a file to AspxBinaryImage? Is there a built-in property available to load from file, such as: AspxBinaryImage.ImageURL="c:\file.jpg" ?
I also wonder the difference between AspxBinaryImage.ContentBytes and AspxBinaryImage.Value. Could you give me an example how to use them?
Hello F G,
The ASPxBinaryImage shows images get from binary data. If your file exists in the file system, you probably can use the ASPxImage, where you should simply define and display an image URL.
> I also wonder the difference between AspxBinaryImage.ContentBytes and AspxBinaryImage.Value.
The ASPxBinaryImage.ContentBytes and Value are the same. Actually the ASPxBinaryImage.ContentBytes is of Byte type, and the Value is Object.
The example with the ASPxBinaryImage is also available in our Code Central: How to bind the ASPxBinaryImage to a field which contains image data stored as OLE object.
Thank you for your example!
As I stated on my question, I need to get the image and treak them on client side. I'v tried AspxImage control. It is easy to load image from file, however, it is impossible to get image data from it and treak the image. Also, if I open and treak an image, I have to save it to server's hard disk before to show the image in AspxImage. That is a round-trip through I/O. That is why I want to try AspxBinaryImage.
>>The ASPxBinaryImage.ContentBytes and Value are the same.
How about its client side function GetValue()? does it return a Byte type data? Similar question about SetValue(object), is "object" must an array Byte?
The ASPxClientBinary image returns nothing when you use the client-side GetValue method. It doesn't return the array of bytes either. If you wish to store bytes somewhere else, you can put them to the ASPxHiddenField directly, and then use it in your code. All image processing (like defining the ContentBytes property) should be performed via the server-side code.
Hello F G,
The ASPxBinaryImage stores images in different modes: ASPxBinaryImage.BinaryStorageMode. Unfortunately there isn't a way to get an array of bytes at the client side. I'm sorry. As well as it is impossible to assign the array of bytes to the ASPxBinaryImage at the client side.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.