diff --git a/kcardgame/binding-example/kcardgame.cpp b/kcardgame/binding-example/kcardgame.cpp index 925e3549..e6ef0d02 100644 --- a/kcardgame/binding-example/kcardgame.cpp +++ b/kcardgame/binding-example/kcardgame.cpp @@ -15,6 +15,15 @@ MyKCardDeck::MyKCardDeck(QString theme_name) d->setDeckContents(ids); d->setCardWidth(150); } +void MyKCardDeck::set_card_height(int i) +{ + d->setCardHeight(i); +} +void MyKCardDeck::set_card_width(int i) +{ + d->setCardWidth(i); +} + QPixmap *MyKCardDeck::get_card_pixmap(int i) { auto ret = new QPixmap(d->cardPixmap(i, true)); diff --git a/kcardgame/binding-example/kcardgame.hpp b/kcardgame/binding-example/kcardgame.hpp index a55a5733..ad4eecef 100644 --- a/kcardgame/binding-example/kcardgame.hpp +++ b/kcardgame/binding-example/kcardgame.hpp @@ -13,4 +13,6 @@ class Q_DECL_EXPORT MyKCardDeck : public QObject explicit MyKCardDeck(QString); public slots: Q_DECL_EXPORT QPixmap *get_card_pixmap(int i); + Q_DECL_EXPORT void set_card_height(int i); + Q_DECL_EXPORT void set_card_width(int i); }; diff --git a/pysollib/ui/tktile/svg.py b/pysollib/ui/tktile/svg.py index 2e6061aa..2d2b4e01 100644 --- a/pysollib/ui/tktile/svg.py +++ b/pysollib/ui/tktile/svg.py @@ -48,9 +48,15 @@ class SVGManager: def render_fragment(self, rank, suit, width, height): if not self.d: return None + d = self.d + # d.set_card_width(width) + d.set_card_width(150) + # d.set_card_height(height) image = Image.fromqpixmap( - self.d.get_card_pixmap( + 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 if 0: id__ = '#' + "queen_heart" """docstring for render_""" @@ -68,4 +74,3 @@ class SVGManager: image = Image.frombuffer('RGBA', (width_, height_), buf, 'raw', 'BGRA', 0, 1) image = self.pixbuf2image(pix) - return image.resize((width, height))