|
I think what you're seeing is a direct inclusion of GDI+. It would have been nice if it had an array accessor though
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Well, you don't have to use LockData; you can use GetPixel() and SetPixel(), which has pretty poor performance, so it's probably not a valid solution.
I've made the same comments to the GDI+ folks. Note that there's going to be more overhead with array-based access regardless of how they do it; not only do you have the array indexing, but you also have the conversion from the bitmap format to the independant format (ie Color).
|
|
|
|
|
Yes, while I imagine Get/SetPixl is not as slow as under GDI, there is at least the overhead of the function calls per pixel.
I'd be happy if they just gave me the data in an array and left it up to me to keep track of where I was, and which was blue, green, red. While I'm on that, why does GDI+ have me specify 24BitRGB, but I get back 24BitBGR ? I know BGR is windows internal format, but why not make the flag that then ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
I havent done a great deal of research into this but I have seen example code in VB.NET that goes something like:
Public Sub DoSomething(sender as Object, e as EventArgs) Handles Button1.Click, Button2.Click, MenuItem1.Click and i really like this new "Handles" clause in defining events.
What I havent seen is the same thing used in C#. I assume you can still use AddHandler and acheive the same thing, though I havent seen that either.
I guess the first question is can you do either of these, but the real question I have is, aside from syntax, personal preference, or the stigma associated with one or the other, why should I choose C# over VB.NET?
Are there things that one does that the other doesnt? Or that one does better, that the other doesnt?
Christian, I notice you have gone straight to C# as your first .NET language. Is it based on anything other than the fact you are more used to typing/seeing braces rather than "End If"?
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
To be honest, I went right for C# because
a/ it's been marketed to me,
b/ it's been presented as the ease of VB/the power of C++,
c/ I have the resources here, and
d/ (sorry, but) I'd be embarrased to choose VB unless I had compelling reasons I could argue for it.
I've discovered tonight that you can use pointers in C#, although I'm not yet sure of the implications of using the unsafe keyword. It appears though that 'unsafe' is the only way I can use the BitmapData class as anything other than a hood ornament.
The very existence of C# AND VB.NET AND Managed C++ to me means that we have two transitional languages to pull people into what M$ want us to develop CLR code in, and that is C#. I am not bailing no C++ at ALL (EVER), but I refuse to use Managed C++ unless a compelling reason arises, because it makes no sense to me to use it. If I want powerful native code, I go to C++, that's why I never learned VB. If I want CLR code, then I will go to C#. I know Managed C++ is optimised, but I think there is more advantage in using the language designed from the ground up with the task in mind.
And in a night I've learned enough to write a program that loads and saves a bitmap, displays it in the dialog and offers an invert filter. Most of that time has been spent figuring out how to use BitmapData, by far, and the answer is in the good old fashoined pointer way, which I didn't realise was possible. As I say, I need now to find out if there are any repercussions of using it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian Graus wrote:
I've discovered tonight that you can use pointers in C#, although I'm not yet sure of the implications of using the unsafe keyword.
unsafe code does compile to IL, but it is unverifiable; so you need a higher permissions set to run the code. The same goes for P/Invoke.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
David Wengier wrote:
I guess the first question is can you do either of these
C# has overloaded the += and -= operators for events so that you can add and remove event handlers at runtime. This is also the only way that C# lets you add event handlers.
The AddHandler statement that you see in VB is VB specific and is part of the VB.NET language. However if you can get access to the underlying EventHandlerList there is an AddHandler method on that you can use. An Events property of type EventHandlerList is exposed on the System.ComponentModel.Component class and its derivatives as well as the System.Web.UI.Control class.
David Wengier wrote:
Are there things that one does that the other doesnt?
VB lets you assign events with the Handles keyword; it is also easier to do Late Binding with VB but you can accomplish the same with some Reflection in C# (or any .NET language).
C# lets you overload operators, and create/use indexers (a property on a class so that you can treat an instance of the class like an array ie foo[3]).
Someone on the DOTNET list noticed that the IL that VB.NET produces has a lot of NOPs in its code generation. While it makes the IL a little bit bigger the JIT will compile those away to nothing.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
All the exmaples I see are making one fat .cs file - what is the equivelant of #include, so I can see the contents of one file from another ?
Thanks
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
You don't. C# -- like Java -- doesn't look for dependencies until the linking stage (if you could call it that).
main.cs
using System;
public class Test
{
public Test() { }
public static void Main(string [] args) {
Foo f = new Foo();
f.SayHello();
}
} foo.cs
using System;
public class Foo
{
public Foo() { }
public void SayHello() {
System.Console.WriteLine("Hello Chrstian!");
}
} That will work just fine, assuming both files are in the compiling process.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Why might it not work ? I did this last night and still got nowhere. If I create a file and save it, do I need to add it to the project somewhere as well ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian Graus wrote:
If I create a file and save it, do I need to add it to the project somewhere as well ?
Yes, it will have to be added to the project or it won't get compiled. How did you go about creating a file and saving it? If you go through the IDE it should be added to the project for you.
How I add a new class: Right click my project in the Solution Explorer, choose Add then Add New xxxxx (class, component, windows form, etc).
Ah! Just a shot in the dark, do the namespaces match between your two files? Come to think of it, my example didn't have a namespace for foo.cs
If you change the namespace you can let the IDE help you a little, right click on the project and choose Properties, then change the Default Namespace to the base namespace you use.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
No, I didn't do it quite like this, but I did it through the IDE. I made sure my namespaces matched, but I'll try it fllowing what you said and see how it goes.
Thanks.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
If you're compiling as part of the same project, you don't need #include; the compiler can automatically access the classes in all the files that are compiled together.
If you're compiling into separate assemblies (aka dlls), you'll need to add the referenced one either to the project or using /r on the command line.
|
|
|
|
|
Thanks - it seems the way I added the file did not make it part of the proejct, I did the exact same thing this morning, but added the class by right clicking in the class view and it all worked fine.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Anybody can tell me how do I get the byte representation of an integer?
E.g. int iValue=500, then the byte representation is 00 00 01 F4.
Thanks.
|
|
|
|
|
int iValue = 500;
byte byte0 = iValue; // byte0 is 0xF4
byte byte1 = iValue >> 8; // byte1 is 0x01
byte byte2 = iValue >> 16; // byte2 is 0x00
byte byte3 = iValue >> 24; // byte3 is 0x00
|
|
|
|
|
Anybody know how can I make a Custom Controls for a ProgressBar to add these functionnalities : SetBkColor, SetBarColor, FlatStyle ?
Thanks
|
|
|
|
|
You can update the enabled/disabled status of menu items using the Popup event for the menu, but how do you update the status for toolbar buttons?
|
|
|
|
|
A toolbar is displayed at all times so you should update it when you need to (ie the button should change state when the button's representive action has changed state).
It makes sense to update a menu in the popup event because the menu isn't always displayed.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Not that I'm a C# programmer or even interested in C#, but I was just wondering how C# would be pronounced in real life. I always thought it was said "C NET."
First Programmer: "How many bits are in a bite?"
Second Programmer: "You spelled bytes wrong."
First Programmer: *stares* "It's a joke, moron."
Second Programmer: "Joke...?"
|
|
|
|
|
|
|
If I understand the discussion of "Deploying a C# App" correctly, you can use the C# compiler to generate an executable that can run on any of the Win OS systems (95/98/ME/NT/2000/XP)...
I am right?
|
|
|
|
|
Windows 95 is not supported
Minimum Configuration Requirements
This section describes the minimum configuration requirements for a computer where the .NET Framework redistributable package is to be installed. If the minimum requirements are not met, Dotnetfx.exe setup will block the installation of the redistributable package. Specifically, note that you cannot install the .NET Framework redistributable package on a computer running the Microsoft Windows 95 operating system.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
But can you make an exe that doesn't need the .NET dlls and stuff...one that would use existing MFC/VB stuff?
|
|
|
|
|