473,466 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

WebClient & graphic objects?

I want to access online graphics for a networked application I am writing &
am having trouble using the WebClient for this. Basically I want the users
to be able to enter an URI to a file either on their local machien or on the
web which they can then use as their icon. I wasnt planning on saving the
file locally - just having in memory. I tried downloading into a byte array
but can find no way of converting that into a graphics object.

Any help on this would be appreciated.

thanks in advance
Phil Crosland
Nov 15 '05 #1
4 1625
string remoteUri = "http://www.contoso.com/library/homepage/images/";

string fileName = "ms-banner.gif", myStringWebResource = null;

// Create a new WebClient instance.

WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebResource = remoteUri + fileName;

myWebClient.DownloadFile(myStringWebResource,fileN ame)

download locally, then use Image.FromFile

"Phil Crosland" <ph****@karmafactory.com.NO_SPAM> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
I want to access online graphics for a networked application I am writing & am having trouble using the WebClient for this. Basically I want the users
to be able to enter an URI to a file either on their local machien or on the web which they can then use as their icon. I wasnt planning on saving the
file locally - just having in memory. I tried downloading into a byte array but can find no way of converting that into a graphics object.

Any help on this would be appreciated.

thanks in advance
Phil Crosland

Nov 15 '05 #2
thanks - ya thats pretty much what I have now - I was hoping to be able to
use the stream though directly into memory for a few reasons not onto files
on local hard disc :/

Phil Crosland

"Kovan" <ju********@rogers.com> wrote in message
news:7y*********************@news01.bloor.is.net.c able.rogers.com...
string remoteUri = "http://www.contoso.com/library/homepage/images/";

string fileName = "ms-banner.gif", myStringWebResource = null;

// Create a new WebClient instance.

WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebResource = remoteUri + fileName;

myWebClient.DownloadFile(myStringWebResource,fileN ame)

download locally, then use Image.FromFile

"Phil Crosland" <ph****@karmafactory.com.NO_SPAM> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
I want to access online graphics for a networked application I am writing
&
am having trouble using the WebClient for this. Basically I want the

users to be able to enter an URI to a file either on their local machien or on

the
web which they can then use as their icon. I wasnt planning on saving the file locally - just having in memory. I tried downloading into a byte

array
but can find no way of converting that into a graphics object.

Any help on this would be appreciated.

thanks in advance
Phil Crosland


Nov 15 '05 #3
Phil,

By your post, I'm not sure exactly sure what you are trying to accomplish
but I'll try an help with creating an System.Drawing.Icon object from a byte
array and then how to draw it to a System.Drawing.Graphics objects.

// Create a Bitmap from a Byte Array already in memory
Icon imgIcon = (Icon) Image.FromStream( new System.IO.MemoryStream(
abytByteArray ) );

// Draw this Icon to a System.Drawing.Graphics object
// in some kind of OnPaint Event from a WinForm Control
e.Graphics.DrawIcon( imgIcon, 0, 0 );

This method could be used to create any class derived from an Image.

Hope this helps.
--
Glen Jones MCSD

"Phil Crosland" <ph****@karmafactory.com.NO_SPAM> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
I want to access online graphics for a networked application I am writing & am having trouble using the WebClient for this. Basically I want the users
to be able to enter an URI to a file either on their local machien or on the web which they can then use as their icon. I wasnt planning on saving the
file locally - just having in memory. I tried downloading into a byte array but can find no way of converting that into a graphics object.

Any help on this would be appreciated.

thanks in advance
Phil Crosland

Nov 15 '05 #4
Thank you! exactly what I was after. slightly altered as the referenced
interent resources coudl be any image type not icons but this is working:

WebClient wcTemp = new WebClient();
byte[] myDataBuffer =
wcTemp.DownloadData(this.txtGeneralFilePath.Text);
//create imTemp from the interent
Image imTemp = Image.FromStream(new
System.IO.MemoryStream(myDataBuffer));

Phil Crosland

"Glen Jones MCSD" <gl********@mailhot.com> wrote in message
news:zt********************@comcast.com...
Phil,

By your post, I'm not sure exactly sure what you are trying to accomplish
but I'll try an help with creating an System.Drawing.Icon object from a byte array and then how to draw it to a System.Drawing.Graphics objects.

// Create a Bitmap from a Byte Array already in memory
Icon imgIcon = (Icon) Image.FromStream( new System.IO.MemoryStream(
abytByteArray ) );

// Draw this Icon to a System.Drawing.Graphics object
// in some kind of OnPaint Event from a WinForm Control
e.Graphics.DrawIcon( imgIcon, 0, 0 );

This method could be used to create any class derived from an Image.

Hope this helps.
--
Glen Jones MCSD

"Phil Crosland" <ph****@karmafactory.com.NO_SPAM> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
I want to access online graphics for a networked application I am writing
&
am having trouble using the WebClient for this. Basically I want the

users to be able to enter an URI to a file either on their local machien or on

the
web which they can then use as their icon. I wasnt planning on saving the file locally - just having in memory. I tried downloading into a byte

array
but can find no way of converting that into a graphics object.

Any help on this would be appreciated.

thanks in advance
Phil Crosland


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MLH | last post by:
I have an AMP application running on linux server that collects, maintains and serves up image files to web clients. On my LAN (in fact, on the same subnet) I have both the linux box and windoze...
2
by: curwen | last post by:
Hi, I have problem to create a well formed xsl-fo document using images dynamically generated from an http request using this tag: <fo:external-graphic content-type="content-type:image/gif"...
72
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools...
0
by: pascal_dumont | last post by:
Hi all, I have a problem with downloading files by using WebClient wc = new WebClient(); wc.DownloadFile("http://some_url.com/some_file.gif", "some_file.gif"); This returns the error 403...
0
by: Martin Maurer | last post by:
Hello, i have a problem with NameValueCollection.Add or better with converting to a QueryString: NameValueCollection myQueryStringCollection = new NameValueCollection();...
9
by: Glen | last post by:
I'm writing a console utility to download specific files from web sites based on the command line options. In most cases, I can trap the 404 error when the file isn't available because the...
2
by: Lila Godel | last post by:
I am having a problem with the download of web pages via the WebClient.DownloadFile function in the specialized VB.Net 2003 I.E. plug-in I am designing to speed up the work on my latest project. ...
1
by: pmz | last post by:
Dear Group, I'm currently developing a simple Windows application in C#, which is supposed to upload images - through 'WebClient' - into remote (FreeBSD/Apache/PHP) server. What is...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.