473,395 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Grab png image from web

There are images from the web that are PNG's that I am trying to grab. I seem to be able to grab them however when I do they are not the same size (in bytes) as the image that is stored on the web. For instance one image I am trying to grab is 2666 bytes, when I grab it the image become 3190 bytes. I am able to save it on my computer if I just right click it in my web browser and it turns out to be the right number of bytes but how can I do this correctly programmatically?

The function that I am using that does it wrong is
Expand|Select|Wrap|Line Numbers
  1.         private static Image pngFromWeb(string URL)
  2.         {
  3.             WebRequest request = WebRequest.Create(URL);
  4.  
  5.             WebResponse response = request.GetResponse();
  6.  
  7.             Image png = Image.FromStream(response.GetResponseStream());
  8.  
  9.             png.Save("C:\\image.png", System.Drawing.Imaging.ImageFormat.Png);
  10.  
  11.             response.Close();
  12.  
  13.             return png;
  14.         }
Dec 16 '08 #1
2 3520
nukefusion
221 Expert 100+
Hi There,
Try using WebClient.DownloadFile() instead.
Dec 17 '08 #2
Thanks, I found this out like a minute after I posted and it worked nice :-)
Dec 20 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ellie | last post by:
I'm stumped. We're building a Struts app running on Websphere on Win2k, with a SQL Server backend. They want pdf files stored in the database; they're in there as Image datatypes. My mission is...
8
by: gregory_may | last post by:
Is there a way to grab a "Screen Shot" that includes "Tool Tips"? I saw this code someplace, cant remember where. But it doesnt grab "Tool Tips". Is there a better way to do this in .net?...
2
by: K.H. | last post by:
Hi Does anyone know how I can grab a video stream from an IP-address? There's a video web server for live image transmission in the Internet. Data transfer is accomplished via TCP/IP. The web cam...
5
by: =?Utf-8?B?U29waGll?= | last post by:
Hi, I try to design a window application to grab attachment from a list of given URL and save them to a user difined folder on their local drive. The list of URL for me to grab attachment will...
1
by: nanaalwi | last post by:
Hi, Currently I'm developing a software using VB.net that can grab an image using Matrox Morphis card and display it in a PictureBox. The software can grab the image already and display it in the...
0
by: David | last post by:
On Sun, May 4, 2008 at 5:28 PM, Valerio Valerio <vdv100@gmail.comwrote: I assume what you want to do is allow the user to drag the mouse across your desktop, and your program, running in the...
2
by: lionbarrage | last post by:
Hi all, I was just wondering if anyone knows how to grab an image from a flv or a swf when a user uploads a file? Any help would be appreciated!
0
by: aromes | last post by:
Hi, How to grab pictures out of online Flash image galleries? I will have the same question for hp/javascript online photo galleries as well (but will post them in their relevant sections unless...
1
by: aromes | last post by:
How to Grab pictures out of online JAVASCRIPT image galleries? Thanks so much
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.