473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ 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 1637
string remoteUri = "http://www.contoso.com/library/homepage/images/";

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

// Create a new WebClient instance.

WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebReso urce = remoteUri + fileName;

myWebClient.Dow nloadFile(myStr ingWebResource, fileName)

download locally, then use Image.FromFile

"Phil Crosland" <ph****@karmafa ctory.com.NO_SP AM> wrote in message
news:eX******** ******@TK2MSFTN GP11.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********@rog ers.com> wrote in message
news:7y******** *************@n ews01.bloor.is. net.cable.roger s.com...
string remoteUri = "http://www.contoso.com/library/homepage/images/";

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

// Create a new WebClient instance.

WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebReso urce = remoteUri + fileName;

myWebClient.Dow nloadFile(myStr ingWebResource, fileName)

download locally, then use Image.FromFile

"Phil Crosland" <ph****@karmafa ctory.com.NO_SP AM> wrote in message
news:eX******** ******@TK2MSFTN GP11.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.FromStrea m( new System.IO.Memor yStream(
abytByteArray ) );

// Draw this Icon to a System.Drawing. Graphics object
// in some kind of OnPaint Event from a WinForm Control
e.Graphics.Draw Icon( 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****@karmafa ctory.com.NO_SP AM> wrote in message
news:eX******** ******@TK2MSFTN GP11.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.Download Data(this.txtGe neralFilePath.T ext);
//create imTemp from the interent
Image imTemp = Image.FromStrea m(new
System.IO.Memor yStream(myDataB uffer));

Phil Crosland

"Glen Jones MCSD" <gl********@mai lhot.com> wrote in message
news:zt******** ************@co mcast.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.FromStrea m( new System.IO.Memor yStream(
abytByteArray ) );

// Draw this Icon to a System.Drawing. Graphics object
// in some kind of OnPaint Event from a WinForm Control
e.Graphics.Draw Icon( 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****@karmafa ctory.com.NO_SP AM> wrote in message
news:eX******** ******@TK2MSFTN GP11.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
1515
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 clients. The window$ boxes are staffed by persons who sometimes email the image files stored on the linux box to various recipients. For simplicity, lets call my linux box L and my windoze box W. Both are nodes on the LAN. Here are the knowns: ...
2
4988
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" src="controller.jsp?page=test&mode=image" /> doesn't work (it says a ';' is missing) the controller.jsp is sending a gif image to the browser and is
72
5395
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 (dreamweaver and the like), they are all at the lowest level of programming (something like assembly as oposed to C++ etc.). These tools create "brain-dead" developers that constantly have to plough through tons of tags to do the simplest thing. ...
0
2414
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 from the server but I can access this files from Internet Explorer without any problems. To further complicate matters this error shows only up at work but works on my home PC.
0
1090
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(); myQueryStringCollection.Add("Test1", null); myQueryStringCollection.Add("Test2","abc"); WebClient myWebClient = new WebClient(); myWebClient.QueryString = myQueryStringCollection;
9
15071
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 operator mistyped the URL or it's offline for whatever reason. The problem I'm running into is with certain sites where the admin has set up a redirect to handle the 404 condition and redirects the request to another page. In this case, the...
2
3247
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. When I edit the web pages in notepad I see a square wherever I normally see a carriage return and a line feed when viewing the source in I.E. How can I make the web pages come down readable so I can easily make my two manual deletions...
1
15437
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 interesting (and the problem) that my script on the remote server side says so: UPLOAD_ERR_PARTIAL (php error) - which means that file was not successfuly (till the eof) uploaded. There is no possibility of any limits (like php.ini - max_file_upload_size,...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
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 we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.