You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (auto context = beginCGContext (true, getDrawMode ().integralMode ()))
I found this out because I was drawing a rotating dial. The rotation works fine (including interpolation), but the offset is rounded to the nearest integral position, causing my dial to jump around within a pixel (screencap video). When I changed the above two lines to match the others, the rotation became smooth.
(I haven't checked this on Windows (only just starting out), so I don't know whether gdiplusdrawcontext.cpp does the same thing.)
The text was updated successfully, but these errors were encountered:
geraintluff
changed the title
[Mac] Why are bitmaps always drawn in integral mode?
[Mac] Bitmaps always drawn in integral mode - is this deliberate?
Jan 15, 2019
Yes, this is intentional. Otherwise bitmaps will be drawn blurry when the scale factor of the transformation matrix is not an integer.
Why don't you pre render your dial and use the CAnimKnob class ?
If the transformation matrix is doing non-integer scaling, then yes, your bitmap's location might land on a non-integer co-ordinate. I didn't see a visual difference when I changed it, except my offsets stopped snapping to the nearest pixel, but admittedly I was also scaling the bitmap so it was interpolating anyway. (Wouldn't that be fairly common though, for a non-integer scale-factor?)
Anyway - if that's the issue, couldn't users enable/disable integral mode for that draw?
This is the same issue as when you draw a line which is meant to be exact-pixel-aligned, but a transform means it's not. I thought choosing what to do in that situation is exactly why "integral mode" is optional?
You'll see the difference when you use a CNinePartTiledBitmap on a scaled context.
And for line drawing, pixel aligned drawing should work with a transform, sure only the start and end point is pixel aligned, but if you choose a line width of exactly one pixel (see CDrawContext::getHairlineSize) then it is pixel aligned.
You've not answered my question, why you don't choose a pre rendered bitmap ?
But anyway, to add an option to draw a bitmap not pixel aligned is always an option. If you like you can work this out and create a pull request.
On Mac the bitmap drawing methods in
CGDrawContext.cpp
always use integral mode:vstgui/vstgui/lib/platform/mac/cgdrawcontext.cpp
Line 609 in 2bf29af
vstgui/vstgui/lib/platform/mac/cgdrawcontext.cpp
Line 573 in 2bf29af
Every other invocation of
beginContext()
in that file uses the integral mode as the second argument, looking like this:vstgui/vstgui/lib/platform/mac/cgdrawcontext.cpp
Line 136 in 2bf29af
I found this out because I was drawing a rotating dial. The rotation works fine (including interpolation), but the offset is rounded to the nearest integral position, causing my dial to jump around within a pixel (screencap video). When I changed the above two lines to match the others, the rotation became smooth.
(I haven't checked this on Windows (only just starting out), so I don't know whether
gdiplusdrawcontext.cpp
does the same thing.)The text was updated successfully, but these errors were encountered: