System.Drawing.Image to System.web.UI.Image
-
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.
VanithaVasu
-
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.
VanithaVasu
u want draw image directly on aspx page From Database
Piyush Vardhan Singh p_vardhan14@rediffmail.com
-
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.
VanithaVasu
VanithaVasu wrote:
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#.
You have to save the Image to the Server (file path) and set the ImageUrl property of the Image control to the file path.
VanithaVasu wrote:
Is there any other way to display directly from the sql where i have stored the image with Image datatype.
You can also use Binary datatype, which is common for all the binary files (doc, xls, whatever)
[Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot
-
VanithaVasu wrote:
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#.
You have to save the Image to the Server (file path) and set the ImageUrl property of the Image control to the file path.
VanithaVasu wrote:
Is there any other way to display directly from the sql where i have stored the image with Image datatype.
You can also use Binary datatype, which is common for all the binary files (doc, xls, whatever)
[Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot
No, I have saved the image in the sql column as image datatype. And i have retrieved the image and converted to bytes[] as in the previous message. I am trying whether it works out from System.Drawing.Image to System.web.UI.Image. My Actual problem is to load the image directly to the treeview icons. Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.
VanithaVasu
modified on Monday, February 11, 2008 6:15 AM
-
No, I have saved the image in the sql column as image datatype. And i have retrieved the image and converted to bytes[] as in the previous message. I am trying whether it works out from System.Drawing.Image to System.web.UI.Image. My Actual problem is to load the image directly to the treeview icons. Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.
VanithaVasu
modified on Monday, February 11, 2008 6:15 AM
VanithaVasu wrote:
Also I don't get "Image" property in the Intelisense box. It shows only the "Image Url" Property. How to define the image.
That is what I am telling you. There is not property as "Image" (which accepts bytes/System.Drawing.Image as value) in web world. So, you have to get the bytes and store it as a file (say mypicture.jpg), then use that image url and assign that to the ImageUrl property of your TreeView icons.
[Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot
-
How can i convert System.Drawing.Image to System.web.UI.Image in asp.net with C#. byte[] storedImage = (byte[])scmd.ExecuteScalar(); MemoryStream stream = new MemoryStream(storedImage, 0, storedImage.Length); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream); bmp.Save(stream, ImageFormat.Gif); Upto this i have . After this what should i do. Is there any other way to display directly from the sql where i have stored the image with Image datatype.
VanithaVasu
You would have to create a seperate page or preferable an http handler for you image. You would set the image url on your tree view to this page with, for example, a query string parameter identifying the image in the database to be retrieved. e.g.
ImageUrl = "MyImagePage.aspx?ImageId=XX";
Then inside your MyImagePage.aspx you would write some code along the lines of that shown below. Note: You must make sure no other content is sent down along with the bytes i.e. no html in the code infront if you use an aspx page (which is one reason why a handler would be better).// Get image bytes from database based on query string byte[] abImageData = (byte[])command.ExecuteScalar(); // Write image to stream Response.ContentType = "image/jpeg"; Response.Write(abImageData); Response.End();