|
look up the formulas and move them into methods
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
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
|
|
|
|
|
like whats the location of the wsdl?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
For getting Pictures from Webpages i use following Code:
---------------------------------------------------------------
WebRequest request = WebRequest.Create("<urltofetch>");
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
Stream local = File.Create("filename.gif");
byte[] buffer = new byte[1024];
int n;
do
{
n = stream.Read(buffer, 0, buffer.Length);
local.Write(buffer, 0, n);
} while (n > 0);
stream.Close();
local.Close();
---------------------------------------------------------------
Where the url can be whatever you want ...
Hope this will help!
|
|
|
|
|
How can I get rid of the beep that happens when I press enter on a form with no default button?
|
|
|
|
|
Add a default button? It seems to me that every form should have a default button, no?
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Unless the application is a simple, one form, dialog application.
Have you tried catching the key down event?
|
|
|
|
|
I tried, but it didn't seem to work.
But I fixed it with a default button that's positioned outside the form
|
|
|
|
|
Ouch. That seems like a bit of a hack. What did you try in terms of capturing the Enter key?
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Sorry, can you tell me where can I download Rotor? I cannot find it
Thanks!
|
|
|
|
|
http://www.sscli.net/
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
What's 'ROTOR'??? I've been hearing alot about that lately...
and instead of actually going to the link provided by the message below this, and finding the answer in 10 seconds. I'd much rather wait a day and, have my question answered here.
/\ |_ E X E GG
|
|
|
|
|
partial sample .net implementation from microsoft with source code (to say it shortly)
|
|
|
|
|
Rotor is the codename (friendly name?) for SSCLI, the Shared Source Common Language Infrastructure. Essentially it's the source for a shared source C# compiler and CLR. If you download it you can see the source for a garbage collector, a C# compiler, how to run managed code in a "sandbox" etc, etc. Of course, there are millions of lines of C** and C# code in there, so it can be a little obtuse <g>.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
So, what... Is it like a ghetto .NET???
/\ |_ E X E GG
|
|
|
|
|
No, it's for the official standardization of the C# language and the CLR for the ECMA. A "reference" version, if you like.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
I am trying to create a Windows Form using C# that can load a dll from the client machine. The dll, uses a COM server to communicate with the COM ports.
The code looks like this so far:
public const string CPH_DLL = "cimphone.dll"; // Import library for Kernel on Win32
[DllImport(CPH_DLL)] public static extern int PingPhone(StringBuilder port);
[DllImport(KER_DLL)] public static extern uint LoadLibrary( string lpFileName );
uint m_hModuleOGL = LoadLibrary(CPH_DLL);
PingPhone("COM2");
The problem is that it is loading the dll on the server and accessing the port on the server. I need it to run on the client running the form.
Any suggestions or tutorials on this subject?
|
|
|
|
|
is there a way to use c# to communicate with the parallel port efficiently. i.e without COM and winows dll imports.
|
|
|
|
|
|
I also needed direct access to the parallel port from C# few months ago I can send you a working sample if you're interested, just let me know.
It is of course not a clean C# solution, I have built a C++ dll which exposes 4 methods that read/write data from/to the specified I/O port, and created a C# wrapper class for these methods.
Also, you need a special driver for windows 2000/XP, because normally executable files don't have direct access to the I/O ports under these OSes. It is called UserPort, I don't remember where did I download it but I can send it to you if you need it too.
Rado
|
|
|
|
|
I'm in the middle of a C# Parallel Port program. I'm using a tweeked out version of the NTPort library...
Can you hook me up with your C++ dll??? I'd like to check it out.
/\ |_ E X E GG
|
|
|
|
|
I've sent a zip archive directly to your e-mail, let me know if you need anything else.
Rado
|
|
|
|
|
why not use a dll whats the difference. If you want to code at the hardware level do c++
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I have a program that does it. It's called "Ghetto Parallel"...
It's not ghetto though. Would you like to check it out??? However, it does use the NTPort Library... and I think you said you didn't want anything like that...
well, if you wanna check it out anyways... email me.
/\ |_ E X E GG
|
|
|
|
|
I have somthing of a problem with databinding objects from a wsdl.exe generated SOAP proxy.
The generated proxy objects expose their data as public fields, rather than properties. DataTextMember will only bind to a property. The only ways round this that I can think of at the moment are:
Wrapper classes for object in the SOAP proxy.
Nope, don't like that idea one bit, Dumb hack.
Use reflection in a generic wrapper class that converts the contained objects fields into properties
Seems overkill, see below.
Wait for an answer here, as I suspect I am missing something obvious to someone else
Ryan.
|
|
|
|