diff --git a/po/de_pysol.po b/po/de_pysol.po index d85b6202..b5cfd1e0 100644 --- a/po/de_pysol.po +++ b/po/de_pysol.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: PySol 0.0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-06-04 21:34-0400\n" +"PO-Revision-Date: 2022-07-06 18:33-0400\n" "Last-Translator: H. Schaekel \n" "Language-Team: German\n" "Language: de\n" @@ -4865,6 +4865,30 @@ msgstr "automatisch skalieren" msgid "&Preserve aspect ratio" msgstr "Seitenverhältnis beibehalten" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/po/fr_pysol.po b/po/fr_pysol.po index 2e9437fe..bc1a2a41 100644 --- a/po/fr_pysol.po +++ b/po/fr_pysol.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: 1.02\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-06-04 21:35-0400\n" +"PO-Revision-Date: 2022-07-06 18:33-0400\n" "Last-Translator: Eric Rausch \n" "Language-Team: French\n" "Language: fr\n" @@ -4912,6 +4912,30 @@ msgstr "Échelle &automatique" msgid "&Preserve aspect ratio" msgstr "Conserver le ratio" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/po/it_pysol.po b/po/it_pysol.po index 4f2535ef..c123af05 100644 --- a/po/it_pysol.po +++ b/po/it_pysol.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: it_pysol\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-06-04 21:35-0400\n" +"PO-Revision-Date: 2022-07-06 18:32-0400\n" "Last-Translator: Giuliano Colla \n" "Language-Team: Italiano \n" "Language: it\n" @@ -4976,6 +4976,30 @@ msgstr "Gira automatico" msgid "&Preserve aspect ratio" msgstr "" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/po/pl_pysol.po b/po/pl_pysol.po index 8afe3107..609678a9 100644 --- a/po/pl_pysol.po +++ b/po/pl_pysol.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-06-04 21:35-0400\n" +"PO-Revision-Date: 2022-07-06 18:32-0400\n" "Last-Translator: Jerzy Trzeciak \n" "Language-Team: Polish \n" "Language: pl\n" @@ -5036,6 +5036,30 @@ msgstr "Przekładaj automatycznie" msgid "&Preserve aspect ratio" msgstr "" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/po/pysol.pot b/po/pysol.pot index df0d233d..16f49e14 100644 --- a/po/pysol.pot +++ b/po/pysol.pot @@ -4663,6 +4663,30 @@ msgstr "" msgid "&Preserve aspect ratio" msgstr "" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/po/ru_pysol.po b/po/ru_pysol.po index 8a1c6779..32e411c7 100644 --- a/po/ru_pysol.po +++ b/po/ru_pysol.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-06-04 21:35-0400\n" +"PO-Revision-Date: 2022-07-06 18:31-0400\n" "Last-Translator: Skomoroh \n" "Language-Team: Russian \n" "Language: ru\n" @@ -5002,6 +5002,30 @@ msgstr "Автоматическое изменение размера" msgid "&Preserve aspect ratio" msgstr "Сохранять соотношение сторон" +msgid "R&esampling" +msgstr "" + +msgid "&Nearest Neighbor" +msgstr "" + +msgid "&Bilinear" +msgstr "" + +msgid "B&icubic" +msgstr "" + +msgid "&Lanczos" +msgstr "" + +msgid "&Antialiasing" +msgstr "" + +msgid "B&ox" +msgstr "" + +msgid "&Hamming" +msgstr "" + msgid "Card la&yout" msgstr "" diff --git a/pysollib/app.py b/pysollib/app.py index e07f171d..3cb0e439 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -877,7 +877,8 @@ class Application: self.opt.spread_stacks, self.opt.preserve_aspect_ratio) = d.scale_values if not self.opt.auto_scale: - self.images.resize(self.opt.scale_x, self.opt.scale_y) + self.images.resize(self.opt.scale_x, self.opt.scale_y, + resample=self.opt.resampling) if d.cardset_values: cs.CARD_XOFFSET, cs.CARD_YOFFSET = d.cardset_values self.opt.offsets[cs.ident] = d.cardset_values diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index abe1cedb..f2139b8a 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -1018,7 +1018,7 @@ class Game(object): self.center_offset = self.getCenterOffset(vw, vh, iw, ih, xf, yf) if (not self.app.opt.spread_stacks or manually): # images - self.app.images.resize(xf, yf) + self.app.images.resize(xf, yf, resample=self.app.opt.resampling) # cards for card in self.cards: card.update(card.id, card.deck, card.suit, card.rank, self) diff --git a/pysollib/images.py b/pysollib/images.py index 5c9e5a14..b254f90a 100644 --- a/pysollib/images.py +++ b/pysollib/images.py @@ -53,6 +53,7 @@ class Images: self.reduced = r self._xfactor = 1.0 self._yfactor = 1.0 + self._resampling = 0 if cs is None: return self._setSize() @@ -430,24 +431,26 @@ class Images: return (int(self.CARD_DX * self._xfactor), int(self.CARD_DY * self._yfactor)) - def resize(self, xf, yf): + def resize(self, xf, yf, resample=1): # print 'Images.resize:', xf, yf, self._card[0].width(), self.CARDW - if self._xfactor == xf and self._yfactor == yf: + if (self._xfactor == xf and self._yfactor == yf + and self._resampling == resample): # print 'no resize' return self._xfactor = xf self._yfactor = yf + self._resampling = resample # ???self._setSize(xf, yf) self.setOffsets() # cards cards = [] for c in self._card: - c = c.resize(xf, yf) + c = c.resize(xf, yf, resample=resample) cards.append(c) self._card = cards # back for b in self._back: - b.image = b.image.resize(xf, yf) + b.image = b.image.resize(xf, yf, resample=resample) # stack bottom image neg = self._bottom is self._bottom_negative # dont know @@ -455,11 +458,11 @@ class Images: bottom_negative = [] bottom_positive = [] for c in self._bottom_negative: - c = c.resize(xf, yf) + c = c.resize(xf, yf, resample=resample) bottom_negative.append(c) self._bottom_negative = bottom_negative for c in self._bottom_positive: - c = c.resize(xf, yf) + c = c.resize(xf, yf, resample=resample) bottom_positive.append(c) self._bottom_positive = bottom_positive @@ -467,11 +470,11 @@ class Images: letter_negative = [] letter_positive = [] for c in self._letter_negative: - c = c.resize(xf, yf) + c = c.resize(xf, yf, resample=resample) letter_negative.append(c) self._letter_negative = letter_negative for c in self._letter_positive: - c = c.resize(xf, yf) + c = c.resize(xf, yf, resample=resample) letter_positive.append(c) self._letter_positive = letter_positive diff --git a/pysollib/options.py b/pysollib/options.py index 584e86e7..7d652ea8 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -28,7 +28,7 @@ import traceback import configobj import pysollib.settings -from pysollib.mfxutil import USE_PIL, print_err +from pysollib.mfxutil import Image, USE_PIL, print_err from pysollib.mygettext import _ from pysollib.mygettext import myGettext from pysollib.pysoltk import TOOLBAR_BUTTONS, TOOLKIT @@ -204,6 +204,7 @@ scale_y = float auto_scale = boolean spread_stacks = boolean preserve_aspect_ratio = boolean +resampling = integer(0, 10) '''.splitlines() @@ -457,6 +458,9 @@ class Options: self.spread_stacks = False self.center_layout = True self.preserve_aspect_ratio = True + self.resampling = 0 + if USE_PIL: + self.resampling = int(Image.ANTIALIAS) # solver self.solver_presets = [ 'none', @@ -611,7 +615,7 @@ class Options: config['cardsets'][str(key)] = val for key in ('scale_cards', 'scale_x', 'scale_y', 'auto_scale', 'spread_stacks', - 'preserve_aspect_ratio'): + 'preserve_aspect_ratio', 'resampling'): config['cardsets'][key] = getattr(self, key) # games_geometry @@ -782,7 +786,8 @@ class Options: ('scale_y', 'float'), ('auto_scale', 'bool'), ('spread_stacks', 'bool'), - ('preserve_aspect_ratio', 'bool')): + ('preserve_aspect_ratio', 'bool'), + ('resampling', 'int')): val = self._getOption('cardsets', key, t) if val is not None: setattr(self, key, val) diff --git a/pysollib/ui/tktile/menubar.py b/pysollib/ui/tktile/menubar.py index 1a2dfb3a..cdadcf2b 100644 --- a/pysollib/ui/tktile/menubar.py +++ b/pysollib/ui/tktile/menubar.py @@ -71,6 +71,46 @@ def createToolbarMenu(menubar, menu): command=menubar.mOptToolbar) +def createResamplingMenu(menubar, menu): + tearoff = menu.cget('tearoff') + submenu = MfxMenu(menu, label=n_('R&esampling'), tearoff=tearoff) + + submenu.add_radiobutton(label=n_("&Nearest Neighbor"), + variable=menubar.tkopt.resampling, + value=int(Image.NEAREST), + command=menubar.mOptResampling) + if Image.BILINEAR: + submenu.add_radiobutton(label=n_("&Bilinear"), + variable=menubar.tkopt.resampling, + value=int(Image.BILINEAR), + command=menubar.mOptResampling) + if Image.BICUBIC: + submenu.add_radiobutton(label=n_("B&icubic"), + variable=menubar.tkopt.resampling, + value=int(Image.BICUBIC), + command=menubar.mOptResampling) + if Image.LANCZOS: + submenu.add_radiobutton(label=n_("&Lanczos"), + variable=menubar.tkopt.resampling, + value=int(Image.LANCZOS), + command=menubar.mOptResampling) + elif Image.ANTIALIAS: + submenu.add_radiobutton(label=n_("&Antialiasing"), + variable=menubar.tkopt.resampling, + value=int(Image.ANTIALIAS), + command=menubar.mOptResampling) + if Image.BOX: + submenu.add_radiobutton(label=n_("B&ox"), + variable=menubar.tkopt.resampling, + value=int(Image.BOX), + command=menubar.mOptResampling) + if Image.HAMMING: + submenu.add_radiobutton(label=n_("&Hamming"), + variable=menubar.tkopt.resampling, + value=int(Image.HAMMING), + command=menubar.mOptResampling) + + # ************************************************************************ # * # ************************************************************************ @@ -177,6 +217,7 @@ class PysolMenubarTkCommon: sound=tkinter.BooleanVar(), auto_scale=tkinter.BooleanVar(), preserve_aspect_ratio=tkinter.BooleanVar(), + resampling=tkinter.IntVar(), spread_stacks=tkinter.BooleanVar(), center_layout=tkinter.BooleanVar(), save_games_geometry=tkinter.BooleanVar(), @@ -236,6 +277,7 @@ class PysolMenubarTkCommon: tkopt.sound.set(opt.sound) tkopt.auto_scale.set(opt.auto_scale) tkopt.preserve_aspect_ratio.set(opt.preserve_aspect_ratio) + tkopt.resampling.set(opt.resampling) tkopt.spread_stacks.set(opt.spread_stacks) tkopt.center_layout.set(opt.center_layout) tkopt.save_games_geometry.set(opt.save_games_geometry) @@ -570,6 +612,8 @@ class PysolMenubarTkCommon: label=n_("&Preserve aspect ratio"), variable=self.tkopt.preserve_aspect_ratio, command=self.mOptPreserveAspectRatio) + submenu.add_separator() + createResamplingMenu(self, submenu) submenu = MfxMenu(menu, label=n_("Card la&yout")) submenu.add_checkbutton( label=n_("&Spread stacks"), variable=self.tkopt.spread_stacks, @@ -1603,6 +1647,15 @@ Unsupported game for import. self.tkopt.preserve_aspect_ratio.set(preserve_aspect_ratio) self._updateCardSize() + def mOptResampling(self, *event): + if self._cancelDrag(break_pause=False): + return + resampling = self.tkopt.resampling.get() + self.app.opt.resampling = resampling + self.tkopt.resampling.set(resampling) # update radiobutton + self.app.opt.resampling = (self.tkopt.resampling.get()) + self._updateCardSize() + def mOptSpreadStacks(self, *event): if self._cancelDrag(break_pause=True): return diff --git a/pysollib/ui/tktile/tkutil.py b/pysollib/ui/tktile/tkutil.py index 720985f7..d6ac38d1 100644 --- a/pysollib/ui/tktile/tkutil.py +++ b/pysollib/ui/tktile/tkutil.py @@ -288,12 +288,12 @@ if Image: im = PIL_Image(image=im) return im - def resize(self, xf, yf): + def resize(self, xf, yf, resample=Image.ANTIALIAS): w, h = self._pil_image_orig.size w0, h0 = int(w*xf), int(h*yf) - im = self._pil_image_orig.resize((w0, h0), Image.ANTIALIAS) + im = self._pil_image_orig.resize((w0, h0), resample) try: findsum = findfile(self._pil_image_orig.filename)