From 4a7c9a761d7ea83ebd133417b348c2302af478c3 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 16 May 2019 19:42:00 +0300 Subject: [PATCH] avoid resizes of the svg. See https://github.com/shlomif/PySolFC/issues/3 . --- kcardgame/binding-example/kcardgame.cpp | 8 ++++++++ kcardgame/binding-example/kcardgame.hpp | 2 ++ pysollib/images.py | 5 +++++ pysollib/ui/tktile/svg.py | 6 +++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/kcardgame/binding-example/kcardgame.cpp b/kcardgame/binding-example/kcardgame.cpp index e6ef0d02..f4b6fde9 100644 --- a/kcardgame/binding-example/kcardgame.cpp +++ b/kcardgame/binding-example/kcardgame.cpp @@ -15,6 +15,14 @@ MyKCardDeck::MyKCardDeck(QString theme_name) d->setDeckContents(ids); d->setCardWidth(150); } +int MyKCardDeck::get_card_height() +{ + return d->cardHeight(); +} +int MyKCardDeck::get_card_width() +{ + return d->cardWidth(); +} void MyKCardDeck::set_card_height(int i) { d->setCardHeight(i); diff --git a/kcardgame/binding-example/kcardgame.hpp b/kcardgame/binding-example/kcardgame.hpp index ad4eecef..96f45f5c 100644 --- a/kcardgame/binding-example/kcardgame.hpp +++ b/kcardgame/binding-example/kcardgame.hpp @@ -13,6 +13,8 @@ class Q_DECL_EXPORT MyKCardDeck : public QObject explicit MyKCardDeck(QString); public slots: Q_DECL_EXPORT QPixmap *get_card_pixmap(int i); + Q_DECL_EXPORT int get_card_height(); + Q_DECL_EXPORT int get_card_width(); Q_DECL_EXPORT void set_card_height(int i); Q_DECL_EXPORT void set_card_width(int i); }; diff --git a/pysollib/images.py b/pysollib/images.py index d4d06237..e19cd956 100644 --- a/pysollib/images.py +++ b/pysollib/images.py @@ -57,6 +57,9 @@ class Images: if cs is None: return self._setSize() + self.CARDW = 100 + self.CARDH = -1 + cs.backnames = [] self._card = [] self._back = [] # bottom of stack (link to _bottom_negative/_bottom_positive) @@ -107,6 +110,8 @@ class Images: if self.CARDW < 0: self.CARDW, self.CARDH = w, h else: + if self.CARDH < 0: + self.CARDH = h if ((check_w and w != self.CARDW) or (check_h and h != self.CARDH)): raise ValueError("Invalid size %dx%d of image %s" % (w, h, f)) diff --git a/pysollib/ui/tktile/svg.py b/pysollib/ui/tktile/svg.py index 2d2b4e01..870b9c33 100644 --- a/pysollib/ui/tktile/svg.py +++ b/pysollib/ui/tktile/svg.py @@ -49,13 +49,13 @@ class SVGManager: if not self.d: return None d = self.d - # d.set_card_width(width) - d.set_card_width(150) + d.set_card_width(width) + print("wh", d.get_card_width(), width, d.get_card_height(), height) # d.set_card_height(height) image = Image.fromqpixmap( d.get_card_pixmap( rank + 1 + {'c': 0, 'd': 1, 'h': 2, 's': 3}[suit]*0x100)) - return image.resize((width, height), Image.LANCZOS) + # return image.resize((width, height), Image.LANCZOS) return image if 0: id__ = '#' + "queen_heart"