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:
parent
c6ff866e51
commit
f5aeecc50d
3 changed files with 18 additions and 2 deletions
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue