Better scaling algorithm for characters of variable size
This commit is contained in:
parent
d3f23708c4
commit
6dd0845f1c
@ -73,6 +73,9 @@ private:
|
|||||||
// These are the X and Y values before they are fixed based on the sprite's width.
|
// These are the X and Y values before they are fixed based on the sprite's width.
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
// These are the width and height values before they are fixed based on the sprite's width.
|
||||||
|
int f_w = 0;
|
||||||
|
int f_h = 0;
|
||||||
|
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
int max_frames = 0;
|
int max_frames = 0;
|
||||||
|
@ -232,14 +232,22 @@ QPixmap AOCharMovie::get_pixmap(QImage image)
|
|||||||
else
|
else
|
||||||
f_pixmap = QPixmap::fromImage(image);
|
f_pixmap = QPixmap::fromImage(image);
|
||||||
auto aspect_ratio = Qt::KeepAspectRatio;
|
auto aspect_ratio = Qt::KeepAspectRatio;
|
||||||
|
auto transform_mode = Qt::SmoothTransformation;
|
||||||
|
|
||||||
if (f_pixmap.size().width() > f_pixmap.size().height())
|
if (f_pixmap.size().width() > this->size().width() && f_pixmap.size().height() <= this->size().height())
|
||||||
aspect_ratio = Qt::KeepAspectRatioByExpanding;
|
{
|
||||||
|
f_pixmap = f_pixmap.scaledToHeight(this->height(), transform_mode);
|
||||||
if (f_pixmap.size().width() > this->size().width() || f_pixmap.size().height() > this->size().height())
|
}
|
||||||
f_pixmap = f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::SmoothTransformation);
|
else if (f_pixmap.size().height() > this->size().height())
|
||||||
|
{
|
||||||
|
f_pixmap = f_pixmap.scaledToWidth(this->width(), transform_mode);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
f_pixmap = f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::FastTransformation);
|
{
|
||||||
|
f_pixmap = f_pixmap.scaled(this->width(), this->height(), aspect_ratio, transform_mode);
|
||||||
|
}
|
||||||
|
this->move((f_w - f_pixmap.width())/2, (f_h - f_pixmap.height())/2);
|
||||||
|
this->resize(f_pixmap.size());
|
||||||
|
|
||||||
return f_pixmap;
|
return f_pixmap;
|
||||||
}
|
}
|
||||||
@ -253,8 +261,9 @@ void AOCharMovie::set_frame(QPixmap f_pixmap)
|
|||||||
void AOCharMovie::combo_resize(int w, int h)
|
void AOCharMovie::combo_resize(int w, int h)
|
||||||
{
|
{
|
||||||
QSize f_size(w, h);
|
QSize f_size(w, h);
|
||||||
|
f_w = w;
|
||||||
|
f_h = h;
|
||||||
this->resize(f_size);
|
this->resize(f_size);
|
||||||
// m_reader->setScaledSize(f_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOCharMovie::get_frame_delay(int delay)
|
int AOCharMovie::get_frame_delay(int delay)
|
||||||
|
Loading…
Reference in New Issue
Block a user