1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

svg : better resize.

This commit is contained in:
Shlomi Fish 2019-05-16 19:12:04 +03:00
parent 80672d8d41
commit 3839df7579
3 changed files with 18 additions and 2 deletions

View file

@ -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));

View file

@ -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);
};

View file

@ -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))