WiredWX Christian Hobby Weather Tools
Would you like to react to this message? Create an account in a few clicks or log in to continue.

WiredWX Christian Hobby Weather ToolsLog in

 


descriptionVisual C++ .NET 2005 Bitmap problem EmptyVisual C++ .NET 2005 Bitmap problem

more_horiz
I'm trying to learn how to modify Bitmaps programatically.

As a first attempt, I'm trying to simply create a blank bitmap, programatically change it to all red, and display it in a pictureBox.

The following code builds without error and, under "Start Without Debugging" runs without error except the blank pictureBox remains blank - no red bitmap is displayed in it. Any suggestions?

Also, forum technical question: this code was properly indented when I entered it, but it semms to be displayed all left justified no matter what I do, including using the "code" tag. How do I make it display properly here?

private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
Bitmap^ TempBitmap;
TempBitmap = gcnew Bitmap(33,33);
Color TempColor;
unsigned char cArg;
unsigned char cRed;
unsigned char cGreen;
unsigned char cBlue;
for (int i=0; i<33; i++)
{
for (int j=0; j<33; j++)
{
cArg = 255;
cRed = 255;
cGreen = 0;
cBlue = 0;
TempColor.FromArgb(cArg,cRed,cGreen,cBlue);
TempBitmap->SetPixel(i,j,TempColor);
}
}
pictureBox1->Image = TempBitmap;
label4->Text = "DONE";
}

Yes, I know it's inefficient to put the color assignments inside the loop because they never change. But, since that's where I'll eventually put color modifications coding, they make good placeholders. Smile...

M. David Johnson
mdj@bds-soft.com

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
Also, forum technical question: this code was properly indented when I entered it, but it seems to be displayed all left justified no matter what I do. How do I make it display properly here?

Further, when I try to edit it using the "Edit" button, the "Send" button at the bottom of the page just seems to return me to the original, unedited post???

M. David Johnson
mdj@bds-soft.com

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
Thanks to Viorel at social_dot_msdn_dot_microsoft_dot_com, the solution is to replace the TempColor assignment line with:

TempColor = Color::FromArgb(cArg,cRed,cGreen,cBlue);

I’ve tested this and it works.

M. David Johnson

:smile2:

Last edited by mdavidjohnson on 20th September 2010, 1:15 pm; edited 1 time in total

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
Hi mdavidjohnson Smile...

Which are you using the express/free or Visual Studio 2005 Professional?


P.S. You probably shouldn't post a live link of your email. Bots come around and pick them up for spam.

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
I'm using Pro.

Version 8.0.50727.42 (RTM.05027-4200) to be exact.

M. David Johnson

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
I'm assuming by your edited post its fixed?

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
Yes, it is indeed fixed.

BTW, I find it rather frustrating that Microsoft often neglects to include usage examples in its Help pages and, even when it does, it often includes only Visual Basic and C# but no Visual C++ usage examples. ( Yes, there are some, but not nearly enough ).

I also have a couple dozen Visual C++ .NET reference books, as well as access to bytes_dot_com, www_dot_codeguru_dot_com, www_dot_ucancode_dot_net, www_dot_deitel_dot_com, and, of course, all the msdn offerings.

But nothing seems to offer a good keyword-by-keyword, function-by-function Visual C++ .NET programming reference; not even so much as a good treatment of when to use . -> or ::.

Have you come across anything of that nature?

M. David Johnson

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
mdavidjohnson wrote:
Yes, it is indeed fixed.

BTW, I find it rather frustrating that Microsoft often neglects to include usage examples in its Help pages and, even when it does, it often includes only Visual Basic and C# but no Visual C++ usage examples. ( Yes, there are some, but not nearly enough ).

I also have a couple dozen Visual C++ .NET reference books, as well as access to bytes_dot_com, www_dot_codeguru_dot_com, www_dot_ucancode_dot_net, www_dot_deitel_dot_com, and, of course, all the msdn offerings.

But nothing seems to offer a good keyword-by-keyword, function-by-function Visual C++ .NET programming reference; not even so much as a good treatment of when to use . -> or ::.

Have you come across anything of that nature?

M. David Johnson



Good.Smile...

I agree. Most of them are vb or C# examples and are unclear. They need to do better.

Same here. I only have one C++ book, but I got all sorts of different ones from C#, Visual Basic, Asp.net to SQL.

I'm more familiar with Visual Basic. Have almost no C++ experience.

Nope. Kinda of a beginner in Visual Basic. Know some, but not enough to build something or anything of this sorts.

descriptionVisual C++ .NET 2005 Bitmap problem EmptyRe: Visual C++ .NET 2005 Bitmap problem

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum