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
80672d8d41
commit
3839df7579
3 changed files with 18 additions and 2 deletions
|
@ -15,6 +15,15 @@ MyKCardDeck::MyKCardDeck(QString theme_name)
|
||||||
d->setDeckContents(ids);
|
d->setDeckContents(ids);
|
||||||
d->setCardWidth(150);
|
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)
|
QPixmap *MyKCardDeck::get_card_pixmap(int i)
|
||||||
{
|
{
|
||||||
auto ret = new QPixmap(d->cardPixmap(i, true));
|
auto ret = new QPixmap(d->cardPixmap(i, true));
|
||||||
|
|
|
@ -13,4 +13,6 @@ class Q_DECL_EXPORT MyKCardDeck : public QObject
|
||||||
explicit MyKCardDeck(QString);
|
explicit MyKCardDeck(QString);
|
||||||
public slots:
|
public slots:
|
||||||
Q_DECL_EXPORT QPixmap *get_card_pixmap(int i);
|
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):
|
def render_fragment(self, rank, suit, width, height):
|
||||||
if not self.d:
|
if not self.d:
|
||||||
return None
|
return None
|
||||||
|
d = self.d
|
||||||
|
# d.set_card_width(width)
|
||||||
|
d.set_card_width(150)
|
||||||
|
# d.set_card_height(height)
|
||||||
image = Image.fromqpixmap(
|
image = Image.fromqpixmap(
|
||||||
self.d.get_card_pixmap(
|
d.get_card_pixmap(
|
||||||
rank + 1 + {'c': 0, 'd': 1, 'h': 2, 's': 3}[suit]*0x100))
|
rank + 1 + {'c': 0, 'd': 1, 'h': 2, 's': 3}[suit]*0x100))
|
||||||
|
return image.resize((width, height), Image.LANCZOS)
|
||||||
|
return image
|
||||||
if 0:
|
if 0:
|
||||||
id__ = '#' + "queen_heart"
|
id__ = '#' + "queen_heart"
|
||||||
"""docstring for render_"""
|
"""docstring for render_"""
|
||||||
|
@ -68,4 +74,3 @@ class SVGManager:
|
||||||
image = Image.frombuffer('RGBA', (width_, height_), buf,
|
image = Image.frombuffer('RGBA', (width_, height_), buf,
|
||||||
'raw', 'BGRA', 0, 1)
|
'raw', 'BGRA', 0, 1)
|
||||||
image = self.pixbuf2image(pix)
|
image = self.pixbuf2image(pix)
|
||||||
return image.resize((width, height))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue