QPixmap xx.scaledToWidth dont Scale but load...
I wand to scale an image on my CMS is this to much work if scale slot is a qslider
or is int width QSize and not pixel?
scaledToWidth ( int width, Qt::TransformationMode mode = Qt::FastTransformation ) const
Code:
/* header */
private:
/* header ..... */
/* i load image */
fileName = OpenFile("Image (*.png)");
if (!fileName.isEmpty()) {
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(ModpicsChanged(int)));
...
centrale->setPixmap
(QPixmap::fromImage(image
));
...
centrale->adjustSize();
actual = centrale->pixmap()->size();
...
horizontalSlider->setSliderPosition(wi);
...
}
/* ..... */
void Gui_Image::ModpicsChanged(int newvalue_w) /* int from QSlider 20px steeps */
{
...
myPixmap = QPixmap::fromImage(image
);
myPixmap.scaledToWidth(newvalue_w,Qt::FastTransformation);
centrale->setPixmap(myPixmap); /* label */
centrale->adjustSize(); /* label */
actual = centrale->pixmap()->size();
...
}
Re: QPixmap xx.scaledToWidth dont Scale but load...
- Why do you use both QImage and QPixmap?
Conversion between QImage and QPixmap costs, especially on X Windows, so better use only QPixmaps (unless you have to access individual pixels).
- Have you read QPixmap::scaledToWidth() docs?
If yes, do it again, but this time very carefully. Pay attention especially to the "const" keyword at the end of signature and the return type.
Re: QPixmap xx.scaledToWidth dont Scale but load...
Quote:
Originally Posted by jacek
- Why do you use both QImage and QPixmap?
Conversion between QImage and QPixmap costs, especially on X Windows, so better use only QPixmaps (unless you have to access individual pixels).
- Have you read QPixmap::scaledToWidth() docs?
If yes, do it again, but this time very carefully. Pay attention especially to the "const" keyword at the end of signature and the return type.
if const at end i make a copy is right? ... now run ... ist very fast on transform... :)
now qt4 taken moore points .... as Imagemagic on server..
But now to save i must go toImage () const : QImage ... QPixmap dont save ... not found
Code:
bool save
( const QString & fileName,
const char * format,
int quality
= -1 ) const
/* running so ..*/
Code:
void Gui_Image::ModpicsChanged(int newvalue_w) /* int from QSlider 20px steeps */
{
qDebug() << "### copyofimagefile... " << copyofimagefile;
QPixmap scaled
= pic.
scaledToWidth(newvalue_w
);
centrale->setPixmap(scaled); /* label */
centrale->adjustSize(); /* label */
actual = centrale->pixmap()->size();
qDebug() << "### Draw image and dispay new W x H px... ";
}
Re: QPixmap xx.scaledToWidth dont Scale but load...
Quote:
Originally Posted by patrik08
if const at end i make a copy is right?
Not quite, const means that this method can't change the object.
http://www.parashift.com/c++-faq-lit...rrectness.html
Quote:
Originally Posted by patrik08
But now to save i must go toImage ()
No, you don't: QPixmap::save()
Re: QPixmap xx.scaledToWidth dont Scale but load...
Quote:
Originally Posted by jacek
Not quite, const means that this method can't change the object.
I see is the same as a define on php but on objekt...
Quote:
Originally Posted by jacek
Ok and quality is same as gimp 70-80...
Much tanks....