From f8f01cd63cb0a7a4d6729867437e5ac4381685d9 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 6 Dec 2023 04:19:34 +0600 Subject: [PATCH] Round numbers in calls to bitmaps --- gui/builtinShipBrowser/fitItem.py | 2 +- gui/builtinShipBrowser/pfBitmapFrame.py | 2 +- gui/builtinViews/fittingView.py | 4 ++-- gui/chrome_tabs.py | 6 +++--- gui/utils/draw.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/builtinShipBrowser/fitItem.py b/gui/builtinShipBrowser/fitItem.py index f641c3ddd..3384fedd7 100644 --- a/gui/builtinShipBrowser/fitItem.py +++ b/gui/builtinShipBrowser/fitItem.py @@ -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) diff --git a/gui/builtinShipBrowser/pfBitmapFrame.py b/gui/builtinShipBrowser/pfBitmapFrame.py index fbf31dced..4f18a88e6 100644 --- a/gui/builtinShipBrowser/pfBitmapFrame.py +++ b/gui/builtinShipBrowser/pfBitmapFrame.py @@ -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) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 62903a2d6..a0c4e2fed 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -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) diff --git a/gui/chrome_tabs.py b/gui/chrome_tabs.py index 3b4cde2db..bca603a04 100644 --- a/gui/chrome_tabs.py +++ b/gui/chrome_tabs.py @@ -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) diff --git a/gui/utils/draw.py b/gui/utils/draw.py index 04c7e6af0..8480a22ba 100644 --- a/gui/utils/draw.py +++ b/gui/utils/draw.py @@ -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)