.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Bitmap to Image Control - ImageUrl

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

 This is my first attempt at using the drawing features of asp.net.  I just want to start simple, and create a single color bar based on a value for a single graph.  I wrote this so far, but I can't figure out how to take the bitmap I just created, and apply it to the Image Control. Do I have to save the file first, and then reload it.

Plus, my box keeps coming out pure black, I trying to fill the box with a color. 

This is part of a web custom control, in which I dynamically created an Image Control. I want to apply the bitmap I made to the image control. 


Dim imgGoogle As Image
imgGoogle = New Image
imgGoogle.ImageAlign = ImageAlign.AbsMiddle
imgGoogle.ImageUrl = cs.GetWebResourceUrl(rsType, "ice5software.BotCatcher.Google.gif")
Private Sub DrawBarGraph_Google(ByVal BarValue As Integer)

	Dim objBitmap As System.Drawing.Bitmap
	Dim objGraphics As S

View Complete Post

More Related Resource Links

Displaying a System.Drawing.Bitmap in a WPF Image control

How would I convert a System.Drawing.Btimap into a comparable WPF image control so I can display in on my WPF window? Thanks

Use update progress control to change image control imageurl

UPDATE: Apologies for the previous formatting error - hopefully the post is now more readable... Hi I have a button with an image control next to it. Before the button is clicked, the image control "ConfirmedStatusImage" shows a "cancel.png" image. When the button has been clicked (and some other code successfully executed), then I change the imageurl for the "theConfirmedStatusImage" to show a "ok.png" image. Quite a bit of time can often pass between clicking the button and the associated code executing, so I have an ajax update progress control that shows a "bluespinner.gif" image while the page is updating after the button click. At the moment, the update progress updating image appears next to the "ConfirmedStatusImage" control. However, I would like to change things so that when the update progress starts, the imageurl of "ConfirmedStatusImage" changes from "cancel.png" to the update progress image (i.e., the "bluespinner.gif"). Then, when the update is complete, then the image should change to the "ok.png" image. My question is: how can I achieve this? As far as I can tell, the update progress control does not have any events that I can hook into. Also, placing the "ConfirmedStatusImage" inside the ProgressTemplate would not work either, as this only displays

image inside custom server control



I want to use an image inside a Custom Web server control ! 

Do I need to use Web.resources ? if so , how to do ?

How to retrieve image from DB with Linq and diplay in Image Control


Hi all-


I'm using the file upload to let the user upload a single file.  Here's the code I'm using to then upload to the DB.  How do I reverse this process and dowload the image into the control for it to display on a different page?

Here's my code for the upload - which I think works but can't confirm until I can see the download since all I see in the DB is "binary data"

'update DB with new Image 
        If FileUpload1.HasFile AndAlso FileUpload1.PostedFile.ContentLength > 0 Then
            'Read the file in to a byte Array.
            Dim filebyte As Byte() = FileUpload1.FileBytes
            Dim fileBinary As New System.Data.Linq.Binary(filebyte)
                Dim c3 = (From c In dc.ProductImages _
                          Where c.userID = userGuid _
                          Select c).FirstOrDefault

                c3.productImage = fileBinary

            Catch ex As Exception
                Throw ex
            End Try
Here's my attempt at the retrieval, which isn't working:
                    Dim currentImage = F

Image "Preloader" Control?

Hi,I am trying to pre-load images in my MasterPage. Normally I just use Javascript like so:<SCRIPT language="JavaScript"> var img = new Image(); img.src="/images/pic.png"; </SCRIPT> How "should" I be doing this in an environment that contains a virtual host, one which is determined by the installer of the application. For example, the application can be installed like this:~/someVirtualDirectory/theapp I'm considering creating a Ajax Server Control to accomplish this task, something like the below or maybe even extending the ImageButton and Hyperlink control to do this by default. Is there a much easier way I am missing?<myDomain:imagePreloader ImageUrl="~/images/pic.png" /> Any help, suggestions, etc. would be appreciated!

Binding byte[] to image control in navigation application leaks

Hi there, I have a (minimal) navigation application with two pages. Page1 contains an image. Switching between pages is done via a buttonhandler in code behind, for instance, (this.NavigationService.Navigate(new Page2())) The image is loaded in code behind via: private void LoadImage() { string fileName = "./images/image.bmp"; if (!new FileInfo(fileName).Exists) throw new Exception("File name doesn't exist"); using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { this.ImageData2 = new byte[fs.Length]; fs.Read(this.ImageData2, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); } } ImageData2 is a byte[] property that sends a propertychange event on changing. ImageData2 is bound to an image in xaml: <Image Grid.Row="1" Source="{Binding Path=ImageData2, Mode=OneTime}"/> When we unload Page1 the following clean up code is executed private void Page_Unloaded(object sender, RoutedEventArgs e) { this.ImageData2 = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } Now, when I start changing pages, I expect the Page we leave to unload, so the GC removes the byte array. However, it doesn't. Am I missing something? Binding the image to a BitmapImage (ImageData1, as you might have guessed:-) ) doesn't leak.

image slider control

Hiiiii Coders, I m designing my home page. Now here i want a section where five images can be displayed one at a time. For displaying five images there will be five buttons. Whenever user will click on first button it will show first image, if he clicks on second button second image should be displayed, similarly if he clicks on third button third image should be displayed and so on. for making things more clear, please visit the url:  http://www.sterlitetechnologies.com/ see the leftmost bottom section of this page How can i achieve this if this is in javascript plz provide complete code as i m newbie to javascript thanx and regards

How convert bitmap to Image.source ?

I hold some bitmap object in the memory  ( simple System.Drawing.Bitmap ). I want to make some wpf image control to show this bitmap. I dont want to save the bitmap to the disk and then load it as URI to the wpf image control So, How can i do this simple action ?   Thanks.

Image control pulling src twice

Hey all, I've created a web part which display a thumbnail image. I'm using the following code:   //Add Thumbnail Image thumbnail = new Image(); thumbnail.Width = 82; thumbnail.Height = 65; thumbnail.ImageUrl = spItems["Thumbnail" ].ToString(); //Create new cell for image TableCell imageCell = new TableCell(); imageCell.CssClass = "thumbnail" ; imageCell.Controls.Add(thumbnail); tRow.Cells.Add(imageCell);   But when it actually renders its pulling the correct source, followed by either the source repeated, or some garbage. Like the source will be   "http://mydev/PublishingImages/myicon.jpg, http://mydev/PublishingImages/myicon.jpg"  which obviously causes the image to not render. Another example is "http://mydev/PublishingImages/myicon.jpg, %20MyIcon" I think it has to do with the type of column I made? I used the URL or Picture column type. Maybe I should just use a single line of text? I wonder if it is grabbing something from the description field? Any thoughts? Am I doing this wrong?


hi everyone     i need some help please  .... (my eng is not very good XD ) i have to pass a webcontrol like a gridview o textbox o label ....to  image(jpg)   dinamic. to download whit the response.addaheader Response.ContentType = "image/jpeg" ;                            Response.AddHeader("Content-Disposition", "attachment;filename=ok.jpg");   i try a lot  of case's and nothing work...  or i have a empty image ..    i try a ..    StringBuilder sb2 = new StringBuilder();         using (StringWriter sw2 = new StringWriter(sb2))         { using (HtmlTextWriter textWriter = new HtmlTextWriter(sw2))        { firmaql.RenderControl(textWriter); }        }  to pass binary[] and then .... byte[] buffer = System.Text.Encoding.ASCII.GetBytes(sb.ToString());       MemoryStream ms = new MemoryStream(buffer, 0, buffer.Length);              ms.Write(buffer, 0, buffer.Length);    

Converting a System.Windows.Control.Image object to byte array.

Hi i need to convert a specific System.Windows.Control.Image object into an (int) array, because i'm trying to convert a silverlight application into a wpf project. private void createGi02GradBrush()<br/> {<br/> WriteableBitmap oWriteableBitmap = new WriteableBitmap(256, 256);<br/> Image oImage = new Image();<br/> oImage.Arrange(new Rect(0, 0, 256, 256));<br/> oImage.Measure(new Size(256, 256));<br/> oImage.Source = new WriteableBitmap(256, 256);<br/> Gi02GradShaderEffect oGi02GradShaderEffect = new Gi02GradShaderEffect();<br/> oGi02GradShaderEffect.pArray = oPImageBrush;<br/> oGi02GradShaderEffect.gi1GradArray = oGi1GradImageBrush;<br/> oImage.Effect = oGi02GradShaderEffect;<br/> oWriteableBitmap.Render(oImage, null);//here<br/> oWriteableBitmap.Invalidate(); <br/> this.oGi02GradImageBrush = new ImageBrush();<br/> this.oGi02GradImageBrush.ImageSource = oWriteableBitmap;<br/> } I've found some similar topics however Image object is not the same and most of its methods aren't available. Here I'm rendering a writablebitmap with a given Image object, but in wpf we need an array. oWriteableBitmap.Render(oImage, null); Any idea? Thanks. Joseph.  

How to Set default file name of image in FileUpload Control

helloi want to set  default value in Fileupload control.Because when i select file name using fileupload then save that file to sqlserver database i got problem when no file is select. so i found alternate of that i should store default image into database through fileupload control but now my query is how to set default image to fileupload control.please i want source code.i really need it......tnx in advance

Background image in Repeater control

Hi, I have a repeater control:<asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource4">                <HeaderTemplate>                </HeaderTemplate>                <ItemTemplate>                    <div >                        <div style="background:url('<%# Eval("HomeSlideBgImage")%>') no-repeat top center" >                        <%# Eval("HomeSlideBgImage")%>                            <h2 id="welcome-heading">                        

Get Rid of Triangle Image on Menu Control

Does anyone know how to get rid of the Triangle that appears on the menu control? I didn't see any properties mentioned in the tree/menu control article by microsoft(http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnvs05/html/treeview.asp). I currently do not have the Beta installed so I don't have the library of docs to check for additional properties. I just want to use an image in the top menu items and want each image to be directly next to each other (Horizontal Configuration) but the Black triangle is getting in the way. Besides actually deleting the image from the server is there a way to do this? Thanks! VC

Me.image1.ImageUrl not displaying image when published


 Hi Everyone,

I have a image control (image1) on a .aspx page and I'm trying to pass in a file system path (not a url) on my Page Load event:

Dim strPictureExists As String = \\rhino\groups\College Photo ID\ & strSID & ".jpg"

Dim strNoPhoto As String = "~/images/nophoto.jpg"

        If File.Exists(strPicture

how to dynamically set image's imagepath (imageURL) in the datalist1



Here i am again , with a new trouble Frown

I put a detalist in my vb.net web page. And bind with datasource, how can i bind a dynamical path on......


i solved by the working on the issue :)) Please find the following answer for setting dynamically setting the imageURL

        Dim img As Image
        Dim y1 As String = DropDownList1.SelectedItem.Value.ToString
        If DropDownList1.SelectedIndex = 1 Then
            y1 = "Genel"

"view state" does't work for Image's ImageURL in dynamic controls


Hi all. in my page_load method I call a mthod that it create some dynamic controls. one of them is an Image control that it's ImageURL property set to an URL that is saved in data base. image shows that URL but when postback ocuurs, previous image controls doesn't their image. but other controls for example TextBoxes keep text values. what should I do for keep image url property for this dynamic Images controls?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend