문제

Can anyone help me resize an image in qt without making the image pixelated. Here's my code. the result is not as good as the original quality..thanks...

QImage img(name);
QPixmap pixmap;
pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::FastTransformation));
QFile file(folder+"/"+name);
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "jpeg",100);
file.close();
도움이 되었습니까?

해결책

You have to pass Qt::SmoothTransformation transformation mode to the scaled function like:

QImage img(name);
QPixmap pixmap;
pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
QFile file(folder+"/"+name);
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "jpeg",100);
file.close();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top