#15497 closed defect (fixed)

wxBufferedPaintDC behaves different than wxPaintDC when using SetLogicalOrigin

Reported by: Eric Raijmakers Owned by:
Priority: normal Milestone:
Component: GUI-generic Version: stable-latest
Keywords: drawing Cc: e.raijmakers@…
Blocked By: Blocking:
Patch: yes

Description

Platform: Windows 7

Applying SetLogicalOrigin(x,y) (x,y !=0) gives different results between wxBufferedPaintDC and wxPaintDC.

How to reproduce:

  • Open drawing sample
  • Start, select Origin -> Move to (100,100), and note the behavior (the whole image is moved (100,100))
  • Now do the same thing, after changing void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event)) {

wxPaintDC pdc(this);
Draw(pdc);

}
to
void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
{

wxBufferedPaintDC pdc(this);
Draw(pdc);

}
NOTE: Add #include "wx/dcbuffer.h" also.

I created a small patch that fixes the problem, but only in part.
After making the change, the image was painted on the correct position, however:

  • the area 'outside the scope' (left and above the new logical origin) is not cleared in the wxBufferedPaintDC whereas for the wxPaintDC it is cleared.
  • when scrolling the window the whole image becomes, well, distorted.


Note that the applied patch 'solves' the problem sufficiently for me, since I already had code that cleared the remaining area in my own application, and in the case where I used the SetLogicalOrigin, the user is not (yet) allowed to scroll. However, I'm not sure what else might go wrong.

Attachments (1)

dcbufcmn.cpp.patch download (524 bytes) - added by Eric Raijmakers 10 months ago.
(partial) Fix that corrects the positioning of the resulting draw operation

Download all attachments as: .zip

Change History (4)

Changed 10 months ago by Eric Raijmakers

(partial) Fix that corrects the positioning of the resulting draw operation

comment:1 Changed 10 months ago by Eric Raijmakers

  • Cc e.raijmakers@… added

comment:2 Changed 10 months ago by vadz

The cropping of the buffer bitmap is difficult to avoid as we'd need to adjust the size of the bitmap used to the origin location, so I don't know how to really fix this.

I'll apply a (variant of) this patch but I don't think it's a good idea to use transformations (of any kind: changing scale, axis orientation etc almost certainly doesn't work neither) with wxBufferedPaintDC1.

comment:3 Changed 10 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74951]) Partially account for the shifted origin in wxBufferedDC.

This change slightly improves wxBufferedDC and wxBufferedPaintDC behaviour
when the origin of the DC is shifted, but they still don't work quite right in
this case as they don't use the buffer area of correct size in this case,
which results in cropping the final bitmap (as can be seen in the drawing
sample, which was modified to show wxBufferedPaintDC in action).

Closes #15497.

Note: See TracTickets for help on using tickets.