Round numbers in calls to bitmaps

This commit is contained in:
DarkPhoenix
2023-12-06 04:19:34 +06:00
parent 21a0e2b9c5
commit f8f01cd63c
5 changed files with 9 additions and 9 deletions

View File

@@ -419,7 +419,7 @@ class FitItem(SFItem.SFBrowserItem):
if not self.dragTLFBmp:
tdc = wx.MemoryDC()
bmpWidth = self.toolbarx if self.toolbarx < 200 else 200
self.dragTLFBmp = wx.Bitmap(bmpWidth, self.GetRect().height)
self.dragTLFBmp = wx.Bitmap(round(bmpWidth), round(self.GetRect().height))
tdc.SelectObject(self.dragTLFBmp)
tdc.SetBrush(wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)))
tdc.DrawRectangle(0, 0, bmpWidth, self.GetRect().height)

View File

@@ -55,7 +55,7 @@ class PFBitmapFrame(wx.Frame):
# todo: evaluate wx.DragImage, might make this class obsolete, however might also lose our customizations
# (like the sexy fade-in animation)
rect = self.GetRect()
canvas = wx.Bitmap(rect.width, rect.height)
canvas = wx.Bitmap(round(rect.width), round(rect.height))
# todo: convert to context manager after updating to wxPython >v4.0.1 (4.0.1 has a bug, see #1421)
# See #1418 for discussion
mdc = wx.BufferedPaintDC(self)

View File

@@ -895,7 +895,7 @@ class FittingView(d.Display):
opts.m_labelText = name
if imgId != -1:
opts.m_labelBitmap = wx.Bitmap(isize, isize)
opts.m_labelBitmap = wx.Bitmap(round(isize), round(isize))
width = render.DrawHeaderButton(self, tdc, (0, 0, 16, 16), sortArrow=wx.HDR_SORT_ICON_NONE, params=opts)
@@ -911,7 +911,7 @@ class FittingView(d.Display):
maxWidth += columnsWidths[i]
mdc = wx.MemoryDC()
mbmp = wx.Bitmap(maxWidth, maxRowHeight * rows + padding * 4 + headerSize)
mbmp = wx.Bitmap(round(maxWidth), round(maxRowHeight * rows + padding * 4 + headerSize))
mdc.SelectObject(mbmp)

View File

@@ -514,7 +514,7 @@ class _TabRenderer:
Creates the tab background bitmap based upon calculated dimension values
and modified bitmaps via InitBitmaps()
"""
bk_bmp = wx.Bitmap(self.tab_width, self.tab_height)
bk_bmp = wx.Bitmap(round(self.tab_width), round(self.tab_height))
mdc = wx.MemoryDC()
mdc.SelectObject(bk_bmp)
@@ -573,7 +573,7 @@ class _TabRenderer:
height = self.tab_height
canvas = wx.Bitmap(self.tab_width, self.tab_height, 24)
canvas = wx.Bitmap(round(self.tab_width), round(self.tab_height), 24)
mdc = wx.MemoryDC()
@@ -1501,7 +1501,7 @@ class PFNotebookPagePreview(wx.Frame):
def OnWindowPaint(self, event):
rect = self.GetRect()
canvas = wx.Bitmap(rect.width, rect.height)
canvas = wx.Bitmap(round(rect.width), round(rect.height))
mdc = wx.BufferedPaintDC(self)
mdc.SelectObject(canvas)
color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)

View File

@@ -21,7 +21,7 @@ def RenderGradientBar(windowColor, width, height, sFactor, eFactor, mFactor=None
def DrawFilledBitmap(width, height, color):
canvas = wx.Bitmap(width, height)
canvas = wx.Bitmap(round(width), round(height))
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)
@@ -37,7 +37,7 @@ def DrawFilledBitmap(width, height, color):
def DrawGradientBar(width, height, gStart, gEnd, gMid=None, fillRatio=4):
if width == 0 or height == 0:
return None
canvas = wx.Bitmap(width, height)
canvas = wx.Bitmap(round(width), round(height))
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)