linking an image file to a dll
-
hi, i need to link an image with a windows control library so that evry time the control is downloaded onto the client side the image also gets downloaded. this is what i'm trying to get. i'm using a windows control on my asp.net page. The code for this control involves creating a graphics object... which in turn displays an image. the problem i'm facing now is how to specify the location of the image file. i can't specify the url as Image.FromFile does not accept urls. Sample code Public Sub DrawImagePoint(e As PaintEventArgs) Dim newImage As Image = Image.FromFile("SampImag.jpg") Dim ulCorner As New Point(100, 100) e.Graphics.DrawImage(newImage, ulCorner) End Sub
-
hi, i need to link an image with a windows control library so that evry time the control is downloaded onto the client side the image also gets downloaded. this is what i'm trying to get. i'm using a windows control on my asp.net page. The code for this control involves creating a graphics object... which in turn displays an image. the problem i'm facing now is how to specify the location of the image file. i can't specify the url as Image.FromFile does not accept urls. Sample code Public Sub DrawImagePoint(e As PaintEventArgs) Dim newImage As Image = Image.FromFile("SampImag.jpg") Dim ulCorner As New Point(100, 100) e.Graphics.DrawImage(newImage, ulCorner) End Sub
You might look at this example of using streams from the quickstart tutorials. http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=%2fquickstart%2fwinforms%2fSamples%2fGDIPlus%2fImages%2fImages.src[^] Torin Blair
'In the immortal words of Socrates - "I drank what?".' -
hi, i need to link an image with a windows control library so that evry time the control is downloaded onto the client side the image also gets downloaded. this is what i'm trying to get. i'm using a windows control on my asp.net page. The code for this control involves creating a graphics object... which in turn displays an image. the problem i'm facing now is how to specify the location of the image file. i can't specify the url as Image.FromFile does not accept urls. Sample code Public Sub DrawImagePoint(e As PaintEventArgs) Dim newImage As Image = Image.FromFile("SampImag.jpg") Dim ulCorner As New Point(100, 100) e.Graphics.DrawImage(newImage, ulCorner) End Sub
Since the embedded WinForm control is running on the client and your image exists on a web server, you're not going to be able to open the file directly. If your project is running in an intranet environment, you may want to simply place the image on a network share. That should allow you to run your code unmodified. If dealing with the web server environment, I'd recommend that you look into using the
HttpRequest
object to retrieve the image from your web server instream
format. Your WinForm control can then construct the image using theImage.FromStream
method. The link that tojamismis provided is a good place to see an example using streams, and MSDN has some good examples of using theHttpRequest
object. Hope that helps. :) --Jesse