对于圆角图片处理,主要使用了四种办法来实现
1.Qt里面使用QPainter来画个
2.QML里面使用opengles来渲染
3.使用原始图片和备用图片来合成
4.使用QML-Canvas来渲染
发现前两种无论如何画出来的还是有些锯齿,虽然设置了抗锯齿,效果不明显
第三种,图片合成,主要是采用图片与图片的z值来产生那种效果,但是一旦换肤就显而易见的有问题
第四种比较满意,效果还不错
先说第一种:
代码:
void YibanImage::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::gray);
painter.setRenderHint (QPainter::HighQualityAntialiasing,true);
painter.drawEllipse(0, 0, 52, 52);
QPixmap icon(currentFileName);
QImage fixedImage(52, 52, QImage::Format_ARGB32_Premultiplied);
fixedImage.fill(0); // Make sure you don't have garbage in there
QPainter imgPainter(&fixedImage);
QPainterPath clip;
clip.addEllipse(0, 0, 52, 52); // this is the shape we want to clip to
imgPainter.setRenderHint(QPainter::HighQualityAntialiasing,true);
imgPainter.setCl