On Sun, 16 Jun 2013 13:42:28 +0000 Stefan Csomor wrote:
SC> I'm still having a m_magnificationFactor internally, I wrapped it into
SC> logicalScale because actually that's was it is
Yes, I understand this, but I think the existing code using logical scale
could easily be broken by the scale being already set on the DCs it
operates on by wxWidgets, where it was always supposed to be governed
exclusively by the user code before. It could be useful to try the drawing
sample with your current changes, I'm almost certain that something in it
must be broken by them.
SC> >SC> calling this with the rawdc could copy logical scale,
SC> >SC>
SC> >SC> double sx, sy;
SC> >SC> raw_dc->GetLogicalScale(&sx, &sy);
SC> >SC> dc.SetLogicalScale(sx, sy);
SC> >
SC> > Yes, I think this ctor should do this.
SC>
SC> with the later changes of creating the bitmap from the dc - it's at the
SC> SelectBitmap moment that MagnificationFactor would be copied back
OK, thinking more about this, I agree with you that we should take the
magnification factor only from the bitmap, not from the source DC. Although
normally they should be the same, shouldn't they?
SC> >SC> wxBitmap(width,height,dc) didn't exist before, so there's no OSX code
SC> >SC> using it, this could be interpreted as above
SC> >SC>
SC> >SC> double sx, sy;
SC> >SC> raw_dc->GetLogicalScale(&sx, &sy);
SC> >SC> bmp.Create(m_rect.GetWidth()*sx, m_rect.GetHeight()*sy);
SC> >SC>
SC> >SC> but that's not what it does under msw - width and height are always in
SC> >SC> pixels,
SC> >
SC> > Well, yes, but again, if we used a separate magnification factor, which
SC> >would be, at least for now, always 1 under MSW, this wouldn't be a
SC> >problem, they'd still remain in pixels.
SC>
SC> but we agree that the 'real' pixels of a
SC>
SC> wxBitmap::Create(width,height,dc)
SC>
SC> would be width*dc.GetMagnification() factor, and that I don't have to do
SC> that multiplication as a wxBitmap user
Just to be sure we're speaking about the same thing: you don't have to do
it in the ctor/Create(). But you'd still have to deal with it if you want
to operate on wxBitmap pixels, right? E.g. you'd have 2*width pixels per
line when using raw bitmap iterators; converting this bitmap to wxImage
would give you a wxImage of size (2*width, 2*height) and so on.
SC> > OTOH I have no idea how are we going to handle having maybe one and maybe
SC> >two bitmap representations of the same bitmap at the API level. We already
SC> >have wxIconBundle which could do this, but it's not really a drop in
SC> >replacement for wxBitmap :-(
I'll continue the discussion below but I don't think you're taking into
account this problem at all, do you? Maybe you think that wxBitmap is never
going to use 2 representations at once because it's always going to be
loaded from either a standard image or a "@2x" one? I'm not sure if this is
true however, as there could be some weird cases like starting a program on
a low DPI external display and then moving its window to the built-in high
DPI display of the notebook. Granted, this is slightly less urgent...
SC> right now bitmaps are drawing via taking their pixel width as logical
SC> width, which on high dpi displays results in blurred bitmaps, so we cannot
SC> change the interpretation there, but I need a way to construct a bitmap
SC> that will be drawn 'pixel by pixel' on such a device.
Wait, I'm starting to be lost again. For me the "logical size" is the size
specified in the ctor. If you also pass wxBitmap ctor a wxDC which has a
magnification factor of 2, the "physical size" of the bitmap will be twice
as big as its logical size. And then if you draw such a bitmap using its
logical size, it will be already drawn "pixel by pixel", i.e. without any
scaling. Am I wrong somewhere here?
SC> Also eg in stc at the moment the backing bitmap is created, there is no
SC> dc around yet, so right now I did a
SC> wxBitmap::CreateScaled(width,height,winid->GetMagnificationFactor())
Good point... So we can't just have a Create(size, dc) after all. Oh well.
SC> So the Create call that takes the dc is ok, if we keep the magnification
SC> factor separate, but I need a name for creating a high-dpi bitmap
SC> explicitly, and for retrieving the 'scaled' ie logical width for such a
SC> bitmap, so right now this would be
SC>
SC> CreateScaled
SC> GetScaledWidth
SC> GetScaledHeight
SC> GetMagnificationFactor
SC>
SC> we need quartett of names, so it could well be
SC>
SC> CreateMagnified
SC> GetScaledWidth
SC> GetScaledHeight
SC> GetMagnificationFactor
SC>
SC> ?
This does seem rather inconsistent :-( So we're back to CreateScaled() and
GetScaleFactor(), I guess.
Regards,
VZ