Click here to Skip to main content
15,916,951 members
Home / Discussions / C#
   

C#

 
GeneraldataGrid1.Width is acting funny Pin
Anonymous20-Aug-03 11:15
Anonymous20-Aug-03 11:15 
GeneralRe: dataGrid1.Width is acting funny Pin
Ista20-Aug-03 14:35
Ista20-Aug-03 14:35 
GeneralRe: dataGrid1.Width is acting funny Pin
A.Wegierski21-Aug-03 7:53
A.Wegierski21-Aug-03 7:53 
GeneralMDI question in C++.Net Pin
Qbus20-Aug-03 11:04
Qbus20-Aug-03 11:04 
GeneralRe: MDI question in C++.Net Pin
Ista20-Aug-03 14:36
Ista20-Aug-03 14:36 
GeneralNeed Help! Pin
t_m2002052120-Aug-03 10:36
t_m2002052120-Aug-03 10:36 
GeneralRe: Need Help! Pin
Ista20-Aug-03 14:37
Ista20-Aug-03 14:37 
Generalloading texture image from a Web Service Pin
Siddharth Jain20-Aug-03 9:44
Siddharth Jain20-Aug-03 9:44 
Hi

I am trying to load a texture from an image I get from a Web Service. D3D provides a method TextureLoader.FromStream using which you can load a texture from a stream. This is the code I wrote to load the texture:

imageRequest = (HttpWebRequest)WebRequest.Create(URL);



URL is something like http://terraservice.net/ogcmap.ashx?version=1.1.1&request=getmap&layers=drg&styles=utmgrid_yellow&srs=epsg:4326&bbox=-122.427,36.66,-117.756,38.947913&width=1000&height=500&format=image/jpeg



imageResponse = (HttpWebResponse)imageRequest.GetResponse();

imageStream = imageResponse.GetResponseStream(); // get a "Stream" from the "Response" object

TextureLoader.FromStream(device, imageStream);

But TextureLoader.FromStream() fn. Gives an error message that “stream does not allow seeking”



Then this is the second thing I tried:

imageRequest = (HttpWebRequest)WebRequest.Create(URL);

imageResponse = (HttpWebResponse)imageRequest.GetResponse();

imageStream = imageResponse.GetResponseStream(); // get a "Stream" from the "Response" object



byte[] buffer = new byte[imageResponse.ContentLength];

imageStream.Read(buffer, 0, (int) imageResponse.ContentLength);

// imageResponse.ContentLength is long so have to cast to int

MemoryStream stream = new MemoryStream(buffer);

texture = TextureLoader.FromStream(device, stream);



but imageResponse.ContentLength is always equal to -1. I was able to save the image by doing:

Image img = Image.FromStream(imageStream);

img.Save("c:/junk/texmap.jpg", ImageFormat.Jpeg);

and it came out fine when i opened it in photoshop.



Then I tried following code (replaced imageResponse.ContentLength by imageStream.Length):

imageRequest = (HttpWebRequest)WebRequest.Create(URL);

imageResponse = (HttpWebResponse)imageRequest.GetResponse();

imageStream = imageResponse.GetResponseStream(); // get a "Stream" from the "Response" object



byte[] buffer = new byte[imageStream.Length];

imageStream.Read(buffer, 0, (int) imageStream.Length);

MemoryStream stream = new MemoryStream(buffer);

texture = TextureLoader.FromStream(device, stream);



but this gives following error while trying to access imageStream.Length while executing

byte[] buffer = new byte[imageStream.Length];



exception of type 'System.NotSupportedException' occurred in system.dll



This stream does not support seek operations.



Any ideas what to do?



sid



GeneralRe: loading texture image from a Web Service Pin
Ista20-Aug-03 16:13
Ista20-Aug-03 16:13 
GeneralRe: loading texture image from a Web Service Pin
Anonymous20-Aug-03 22:42
Anonymous20-Aug-03 22:42 
GeneralGetting rid of the enter beep Pin
S O S20-Aug-03 9:25
S O S20-Aug-03 9:25 
GeneralRe: Getting rid of the enter beep Pin
Julian Bucknall [MSFT]20-Aug-03 10:33
Julian Bucknall [MSFT]20-Aug-03 10:33 
GeneralRe: Getting rid of the enter beep Pin
Alex Korchemniy20-Aug-03 12:47
Alex Korchemniy20-Aug-03 12:47 
GeneralRe: Getting rid of the enter beep Pin
S O S20-Aug-03 21:18
S O S20-Aug-03 21:18 
GeneralRe: Getting rid of the enter beep Pin
Julian Bucknall [MSFT]21-Aug-03 5:14
Julian Bucknall [MSFT]21-Aug-03 5:14 
GeneralCan't find the rotor Pin
Cristoff20-Aug-03 8:33
Cristoff20-Aug-03 8:33 
GeneralRe: Can't find the rotor Pin
Julian Bucknall [MSFT]20-Aug-03 10:31
Julian Bucknall [MSFT]20-Aug-03 10:31 
GeneralRe: Can't find the rotor Pin
eggie520-Aug-03 17:26
eggie520-Aug-03 17:26 
GeneralRe: Can't find the rotor Pin
Cristoff20-Aug-03 21:17
Cristoff20-Aug-03 21:17 
GeneralRe: Can't find the rotor Pin
Julian Bucknall [MSFT]21-Aug-03 5:18
Julian Bucknall [MSFT]21-Aug-03 5:18 
GeneralRe: Can't find the rotor Pin
eggie521-Aug-03 12:42
eggie521-Aug-03 12:42 
GeneralRe: Can't find the rotor Pin
Julian Bucknall [MSFT]21-Aug-03 14:57
Julian Bucknall [MSFT]21-Aug-03 14:57 
Generalaccessing dll from client form Pin
Mike J Carr20-Aug-03 8:21
Mike J Carr20-Aug-03 8:21 
Generalcommunicating with parallel port Pin
manusha20-Aug-03 7:06
manusha20-Aug-03 7:06 
GeneralRe: communicating with parallel port Pin
leppie20-Aug-03 7:49
leppie20-Aug-03 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.