Bug in wxDC? 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
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Bug in wxDC?

Post by lester »

When I try to draw on wxMemoryDC I have found strange effect with some bitmaps - please see attachments.

I use this code for draw picture:

Code: Select all

						double sx, sy;
						dc->GetUserScale( &sx, &sy );

						int wleft = a_aPart[ i ].Rect.GetLeft() * sx;
						int wtop = a_aPart[ i ].Rect.GetTop() * sy;
						wtop += y;

						wxPoint tOrigin = dc->GetDeviceOrigin();
						dc->SetDeviceOrigin( wleft, wtop );
						dc->DrawBitmap( a_aPart[ i ].Picture, 0, 0, true );

						dc->SetDeviceOrigin( tOrigin.x, tOrigin.y );
For wxPrinterDC all work fine
Attachments
Wrong
Wrong
Right
Right
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

What version of widgets?
What plaftorm?
What compiler?

Whats the problem? the right and wrong screen caps seem to be of different images. What are we supposed to be looking for?

Try posting the rest of your code. Ie the transfer of the wxMemoryDC to the wxPrinterDC and I assume a wxPaintDC?

This post leaves a lot unexplained. Remember, when code doesn't work calling bug shouldn't be the first place you go. Rather look at your own code first. Not to say wxWidgets is bug free, it isn't. But, problems here being due to a bug in wxWidgets are the exception not the rule.

-Max
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

wxWidgets 2.8.4
Win XP Pro
Visual Studio 2005


When I draw some bitmaps on wxMemoryDC ( not all ) result image was wrong - must be white page with data

I use wxPrintout for render/print pages, that's part of code for get page preview:

Code: Select all

		m_pPrint->SetPageSizePixels( tSize.x, tSize.y );

		wxBitmap t_bmpMini( tSize.x, tSize.y );
		wxMemoryDC tDC( t_bmpMini );
		tDC.SetPen( *wxWHITE );
		tDC.SetBrush( *wxWHITE );
		tDC.DrawRectangle( 0, 0, tSize.x, tSize.y );

		m_pPrint->SetDC( &tDC );
		m_pPrint->OnPrintPage( inNumber );
		tDC.SelectObject( wxNullBitmap );
so atleast background must be white - not transparent

On attachments difference only in bitmap that I load and draw on wxMemoryDC, so result must be identical ( except bitmaps )

About "Remember, when code doesn't work calling bug shouldn't be the first place you go. Rather look at your own code first" - keep cool, I'm not child

P.S. sorry for my bad english
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

lester wrote:About "Remember, when code doesn't work calling bug shouldn't be the first place you go. Rather look at your own code first" - keep cool, I'm not child
Then don't cry like one. Since we are all adults an honest and cool critique shouldn't cause offense.

There still seems to be some code missing (or maybe I am not understanding).

The english isn't that bad ( no need for apologies), but I am still a little unsure of the exact problem. Could you include screen capture of the same image working and not working? Also, a little more code might help bridge the language gap.

-Max
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

mc2r wrote: Then don't cry like one. Since we are all adults an honest and cool critique shouldn't cause offense.
Certainly, but I want get answer - is it wxWidgets bug or not and how fix it, please attentively read title, so your advice was useless

I cannot post all code - it placed in many files, but there steps one by one:

1. Transfer data to my child of wxPrintout
2. Request page preview from Printout:

Code: Select all

                m_pPrint->SetPageSizePixels( tSize.x, tSize.y );

                wxBitmap t_bmpMini( tSize.x, tSize.y );
                wxMemoryDC tDC( t_bmpMini );
                tDC.SetPen( *wxWHITE );
                tDC.SetBrush( *wxWHITE );
                tDC.DrawRectangle( 0, 0, tSize.x, tSize.y );

                m_pPrint->SetDC( &tDC );
                m_pPrint->OnPrintPage( inNumber );
                tDC.SelectObject( wxNullBitmap );
3. Draw page in Printout - please see first post
4. Get result bitmap and draw it on screen

On attachments two identical reports which difference only in picture that shown on top
Attachments
1.png
2.PNG
2.PNG (39.58 KiB) Viewed 2143 times
Sample of picture that break result
Sample of picture that break result
document.png (582 Bytes) Viewed 2144 times
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

lester wrote:
mc2r wrote: Then don't cry like one. Since we are all adults an honest and cool critique shouldn't cause offense.
Certainly, but I want get answer - is it wxWidgets bug or not and how fix it, please attentively read title, so your advice was useless
It is only useless if you don't listen and I really don't have time to waste on someone not willing to listen. I see you still haven't posted all the relevant code. Also, it is still not clear whats wrong between the two because they are different images so its kind of hard to compare them for what is DIFFERENT? But stubbornly don't help those trying to help you and see how far that goes to solving your problem.

-Max
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

mc2r wrote: It is only useless if you don't listen and I really don't have time to waste on someone not willing to listen. I see you still haven't posted all the relevant code. Also, it is still not clear whats wrong between the two because they are different images so its kind of hard to compare them for what is DIFFERENT? But stubbornly don't help those trying to help you and see how far that goes to solving your problem.

-Max
I don't want to spend your time, sorry if I did, maybe You must react less actively on my stupid comments

About DIFFERENT:
When I try to draw "wrong" bitmap on DC all DC make transparent and I loss all another data that I draw on it

once again sorry for english - probably that's reason for our inexpensively
tan
wxWorld Domination!
wxWorld Domination!
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan »

Hi,
lester wrote: About DIFFERENT:
When I try to draw "wrong" bitmap on DC all DC make transparent and I loss all another data that I draw on it
I still don't understand the problem as well :)
Definitely, you have to post more code and explanations.
lester wrote: once again sorry for english - probably that's reason for our inexpensively
Well, we have Russian forum now :)
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

tan wrote:Hi,
lester wrote: About DIFFERENT:
When I try to draw "wrong" bitmap on DC all DC make transparent and I loss all another data that I draw on it
I still don't understand the problem as well :)
Definitely, you have to post more code and explanations.
lester wrote: once again sorry for english - probably that's reason for our inexpensively
Well, we have Russian forum now :)
Problem:
1. I draw something on DC
2. I draw bitmap on DC - after this DC make empty and we have only this bitmap drawn on it
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

lester wrote:I don't want to spend your time, sorry if I did, maybe You must react less actively on my stupid comments
Then don't apologize and do post some more code ;)
lester wrote:once again sorry for english - probably that's reason for our inexpensively
Don't worry about the english. Most people here are very tolerant. But it does help to post code as it is the same in all languages (excepting variable names). The code also helps seeing what exactly you are doing. As the problem most often lies in the implementation and not the algorithm it helps to see what exactly you are doing.

I know it can be a pain to post real code as it is usually over several files with lots of code irrelevant to the problem. But if you could get a minimal example that shows the problem, it would help greatly.

-Max
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

mc2r wrote:
lester wrote:I don't want to spend your time, sorry if I did, maybe You must react less actively on my stupid comments
Then don't apologize and do post some more code ;)
lester wrote:once again sorry for english - probably that's reason for our inexpensively
Don't worry about the english. Most people here are very tolerant. But it does help to post code as it is the same in all languages (excepting variable names). The code also helps seeing what exactly you are doing. As the problem most often lies in the implementation and not the algorithm it helps to see what exactly you are doing.

I know it can be a pain to post real code as it is usually over several files with lots of code irrelevant to the problem. But if you could get a minimal example that shows the problem, it would help greatly.

-Max
big thanks for understanding, I'll prepare sample project after few hours
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

Please remove this topic, I will create new normal with samples after
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester »

I have found solution, now I use wxImage for remove mask:

Code: Select all

	wxImage tImage = t_bmpMini.ConvertToImage();
	tImage.SetMask( false );
	t_pResult = new wxBitmap( tImage );
I this way result bitmap shown full
Post Reply