.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

Get Image from HTTP in a System.Drawing.Image

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

How can i get a Image that exitsts on the WWW, into my project.
Normally i get a image on this way:


        System.Drawing.Image ImgWatermerk = System.Drawing.Image.FromFile(PNGPath);


But right now the image is remote like http://www.google.nl/google.jpg


View Complete Post

More Related Resource Links

System.Drawing.Image.Fromfile is not working


I am trying to get the height and width of the image dynamically.  The reason is I am loading multiple images using code, where the image name is from the database. 

Here is my code:

in the ascx page, I have an asp image

<asp:image id="imgInfo" runat="server" /> 


In the code behind

string ImagePath = "~/products/img/" + dataviewImgInfo[0]["imgName"].ToString();

System.Drawing Image imgProd = System.Drawing.Image.FromFile(ImagePath);

if(imgProd.Height > 200)

imgInfo.Height = 100;




imgInfo.Height = 200



WHen I run this page I am getting the folloiwng error

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

System.Drawing.Image.FromFile crashes for tiff files on 64bit system


The following pice of code runs fine on my development machine (win7, 32bit) but ends with Exception on the server (Win2008R2, 64bit).


        static void Main(string[] args)


            Image image = Image.FromFile(args[0]);





The exception will be thrown for TIFF files (from other sources) but ie not for PNG files.

I was wondering why the test program above works fine on my Win 32bit machine with .NET 4 but not on my 64bit machine with .NET 4.

Any help appreciated.



How to Convert System.Drawing.Image Variable to Byte variable



I got a variable of type System.Drawing.Image and need to convert it to a variable of type byte so I can store the image in the database. Can someone show me how to do that in VB.NET code.

Thanks alot

System.Drawing.Image.FromStream() ArgumentException: Parameter not valid.


I am getting an ArgumentException: Parameter is not valid.

Does anyone know what's wrong with my code here?

        ImgService obj = new ImgService();

        byte[] data = obj.ShowImg(6);

        Int32 offset = 78;

        MemoryStream memStream = new MemoryStream();

        memStream.Write(data, offset, data.Length - offset);

        System.Drawing.Image img = System.Drawing.Image.FromStream(memStream);

        img.Save(Server.MapPath("image.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);


        Image1.ImageUrl = Server.MapPath("image.jpg");


        ImgService obj = new ImgService();

        byte[] data = obj.ShowImg(6);
        Int32 offset = 78;

System.Drawing.Image.FromStream() get a Parameter is not valid


Anyone help fix Parameter is not valid errors , when i tried rename and save a file using fileupload to server

my code here :

if (fupImage.PostedFile.FileName != "")
                if (!Utitlties.Instance.CheckImageFileType(fupImage.PostedFile.FileName))
                    lblMessageForfupImage.Visible = true;
                    lblMessageForfupImage.Text = "Image file only accept *.jpg, *.png, *.bmp, *.gif Extensions !";
                    evt.ImageURL = Utils.Instance.SaveImage(fupImage.PostedFile.InputStream, fupImage.PostedFile.FileName, true);

anh here is methos SaveImage :


public string SaveImage(Stream stream, string filename, bool IsImageFile/*, bool CreateThumImage*/)
        string ImgUrl = string.Empty;
        string d = Utitlties.Instance.MakeFolderName();
        System.Drawing.Image img;
        string dirToSave = HttpContext.Current.Server.MapPath("Images/Uploads") + "/" + d + "/";
        string dir = "Images/Uploads/" + d + "/";
            if (IsImageFile == true)

ImageList and a system image list handle

How can I have an ImageList use an image list handle of a systems image list, such as one that can be returned from SHGetFileInfo ? My image list is associated with a ListView control and this could be easily done in Win32 through the LVM_SETIMAGELIST message with an image list handle but I see no easy way of doing this with the .Net System.Windows.Forms.ImageList component.

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.  

WCF: Read file system image and return image thru wcf



I have a service which reads an image stored in the database. I want to be able to read an image stored on the file system and return that back to the requestor, is that possible?

Thanks for your help! :)


Delete Image file from file system


Hi guys,

I have a web site that you can upload images, the image path is saved in the ImgPath field in the data database and retrieves the image and displays it in the grid view. I want to be able to delete the image from a folder within my project when I delete the record. I'm trying to delete it from the Detailsview_ItemDeleting event.

Thanks for you help .

Drawing and saving a vector image (emf/wmf or anything MSWord/PPT can read)


Hi! I've been tasked with generating graphs of data as images for the purpose of importing into MS Word documents and Powerpoint presentations.

I've done it using GIF images, but I'd really like to use a vector format, so they can be scaled in the document without losing quality, and of course keeping the document size down as there's lots of them.

MS Word and Powerpoint can import EMF, WMF and CGM formats, but I have no idea how to generate those in .NET.

Does anyone have some pointers for me to get started creating say EMF files from .NET?  I've looked all over the net and can't find much at all about it... I've gathered it's a job for GDI+, but can't find sample code or anything for .NET.

Many thanks!

Built-in Functions - Text and Image Functions in SQL Server

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

Future versions of SQL Server will not support TEXT, NTEXT and IMAGE data types. Columns with TEXT / NTEXT data type do not support commonly used string functions such as LEN, LEFT, RIGHT, etc. Furthermore, due to the large size of TEXT data you''re likely to see performance issues if you store such data in the database. However, at times you can''t help but use the TEXT / NTEXT / IMAGE data types (for example when supporting 3rd party databases when you cannot change the schema) - this is when text and image functions come in handy.

Program for Format Conversion of An Image

.NET provides extensive support for image conversion. Any image can be processed from one format to another. Most common formats to which .NET have support for are .BMP, .EMF, .GIF, .ICO, .JPG, .PNG, .TIF and .WMF.

Configuring Profile Image Export in SharePoint 2010

It's no secret that I am thrilled with the new social features of SharePoint 2010. I am most excited about the new Profile Picture handling. I strongly believe that the more we can show the faces of our colleagues to one another the more connected we will feel. Clearly Microsoft feels that way as witnessed by the many features that make use of the Profile Image like the Activity Feed and Colleagues list

Built-in Functions - Text and Image Functions

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

ASP.Net Upload Image to MS Access Database

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table "tblImg" with the following fields:

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:
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