Button bitmap with 2.6.0 Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
MatthewDP
Earned a small fee
Earned a small fee
Posts: 16
Joined: Thu Apr 21, 2005 6:19 am

Button bitmap with 2.6.0

Post by MatthewDP »

Hi all,

wxWidgets 2.6.0, MSW XP SP2

I updated from 2.4.2 to 2.6.0 and I ran into a problem.
When adding bitmap pictures to my toolbar buttons, the bitmaps appear to be inverted in color. [I'm not sure it's exactly a color inversion, but the normal gray background is now green, and all the colors are different.]

Additionally, a button that is set as disabled is now completely grayed-out -- the image is just a blank gray square instead of the normal "unenabled" looking picture that was there before.

I have included the code below. Any idea how to fix the problem?

Thanks for your help,
Matt.

Code: Select all

	wxBitmap newBmp;
	if(!newBmp.LoadFile((m_configs.getAppDirectoryPath().string() + "/Img/ButtonNew.bmp").c_str(), wxBITMAP_TYPE_BMP))
		newBmp.Create(15,15);

	wxBitmap openBmp;
	if(!openBmp.LoadFile((m_configs.getAppDirectoryPath().string() + "/Img/ButtonOpen.bmp").c_str(), wxBITMAP_TYPE_BMP))
		openBmp.Create(15,15);

	wxBitmap saveBmp;
	if(!saveBmp.LoadFile((m_configs.getAppDirectoryPath().string() + "/Img/ButtonSave.bmp").c_str(), wxBITMAP_TYPE_BMP))
		saveBmp.Create(15,15);

   const int ID_TOOLBAR = 500;
   long style(0);
   style &= ~(wxTB_NOICONS);
   style |= wxTB_FLAT | wxTB_TEXT | wxTB_HORIZONTAL;

	//Create and fill the tool bar
        wxToolBar* toolBar = this->CreateToolBar(style, ID_TOOLBAR);

	int toolID = IDtb_New;
	toolBar->AddTool(IDtb_New, "New", newBmp);
	toolBar->AddTool(IDtb_Open, "Open", openBmp);
	toolBar->AddTool(IDtb_Save, "Save", saveBmp);

   //Realize the toolbar
   toolBar->Realize();
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Try converting the images to png, it will save space too, and also your problem may be solved. I think its the palette problem, set the palette of the dc by the bitmap pallete.
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Code: Select all

newBmp.Create(15,15);
Any body have a idea, what this is doing after loading the image, it that necessary. I haven't used it.
ssigala
Earned some good credits
Earned some good credits
Posts: 109
Joined: Fri Sep 03, 2004 9:30 am
Location: Brescia, Italy

Post by ssigala »

priyank_bolia wrote:

Code: Select all

newBmp.Create(15,15);
Any body have a idea, what this is doing after loading the image, it that necessary. I haven't used it.
I suppose MatthewDP want to do something like: load the bitmap from the disk or (if cannot load) create at least an empty bitmap.
Sandro Sigala - Kynosoft, Brescia
MatthewDP
Earned a small fee
Earned a small fee
Posts: 16
Joined: Thu Apr 21, 2005 6:19 am

Post by MatthewDP »

Re: creating a blank bitmap if the other is not loaded, that was exactly my intention. If I couldn't load the bitmap, I wanted some way to continue to run the application. This just guarantees that a bitmap is available.

Perhaps I could do something else, but that's a quick solution for now.
MatthewDP
Earned a small fee
Earned a small fee
Posts: 16
Joined: Thu Apr 21, 2005 6:19 am

Post by MatthewDP »

I re-saved the bitmaps as 24-bit bitmap images (from MS Paint). This solved the problem. I'm not sure what exact format they were before (16 or 256). But 24 bit seems to work.

Thanks,
Matt.
Post Reply