Visual Studio C++ pictureBox

Associate
Joined
4 Jun 2003
Posts
770
Location
United Kingdom
Hi all,

If I use a picture box in a program and use the command:

pictureBox1->Load

to draw a picture to the pictureBox how do I then access the pixels of that picture and get the length and width back?

Thanks
 
I was going to do it in standard C++ but I'll change to .NET, can't be hard to pick up.

How do I start a C++ .NET project in Visual Studio 2005? I need it to have a Windows Forms feel to it i.e. and easy to implement and change GUI.

Thanks
 
I've got it stuck in C++ mode, it seems to auto create a C++ project.

Do you know how I change it?

(I'm not overly familiar with VS, I'm used to Borland Builder)
 
Ahh I think I understand, it's possible to use multiple language types in one project? Selecting Windows Forms Application allows C++ code and C++ .NET code to be written into the same project?

Where should I declare the Bitmap imageBitmap so that it is accessible throughout the program?

Again, probably a stupid question, but Borland works differently.
 
I'm having to use the following instead of what you advised:

Bitmap imageBitmap = gcnew Bitmap(pictureBox1->Image);

imageBitmap.SetPixel(x, y, pixelColour);

Anyhow, I can now draw to pixels and get their colours back, but how do I update the pictureBox image with the modified imageBitmap? I tried

pictureBox1->Load(imageBitmap);

but it didn't like it.

Last question, how do I get the individual RGB values for the pixels of an image?

Thanks
 
Thanks for the guidance, I'll have a go.

I'm still having trouble redrawing the bitmap to the pictureBox image though, it gives me an error:

cannot convert parameter 1 from 'System::Drawing::Bitmap' to 'System::Drawing::Image ^'

Maybe I would be better if I could get it to create a C++ .NET project?

When I got File->New->Project the project types are listed as Visual C++ and from there I select Windows Forms Application. There's no mention of .NET anywhere.
 
Inquisitor said:
Code:
Bitmap^ imageBitmap = gcnew Bitmap(pictureBox1->Image);

THANKS!

You're a star, this has enabled me to use

Code:
imageBitmap->SetPixel(x,y,pixelColour);

&

pictureBox->Image = imageBitmap;

I think I'm beginning to understand VS now, it has some things which are a lot nicer than Borland. I just need to understand this .NET malarky now, might have to get a good book.
 
Inquisitor said:
I'd definitely recommend getting a book, they're a huge help when it comes to learning a language (even if you already understand the gist of it). Perhaps one that focuses mainly on the .NET framework, rather than C++ itself?

Yeh definitely. I have a pretty good understanding of C++ so picking up most languages isn't a problem but a book definitely helps. I do need toget to grips with .NET though.

Am I right in thinking its Microsofts version of Java essentially?
 
Back
Top Bottom