我是这样加载的一张图片 QImage mag(“a.png”);
然后更改了mag的ALPHA通道 ,我手动更改的 就是把每个像素的第四位赋值了
但是QPainter好像没管ALPHA通道 求解释
问题解决了 convertToFormat转换下格式
但是又有新问题了 转换前和转换后每一个像素里面的数据都一摸一样 为啥就显示不一样呢
######bool QImageReader::read(QImage *image)
{
if (!image) {
qWarning("QImageReader::read: cannot read into null pointer");
return false;
}
if (!d->handler && !d->initHandler())
return false;
// set the handler specific options.
if (d->handler->supportsOption(QImageIOHandler::ScaledSize) && d->scaledSize.isValid()) {
if ((d->handler->supportsOption(QImageIOHandler::ClipRect) && !d->clipRect.isNull())
|| d->clipRect.isNull()) {
// Only enable the ScaledSize option if there is no clip rect, or
// if the handler also supports ClipRect.
d->handler->setOption(QImageIOHandler::ScaledSize, d->scaledSize);
}
}
if (d->handler->supportsOption(QImageIOHandler::ClipRect) && !d->clipRect.isNull())
d->handler->setOption(QImageIOHandler::ClipRect, d->clipRect);
if (d->handler->supportsOption(QImageIOHandler::ScaledClipRect) && !d->scaledClipRect.isNull())
d->handler->setOption(QImageIOHandler::ScaledClipRect, d->scaledClipRect);
if (d->handler->supportsOption(QImageIOHandler::Quality))
d->handler->setOption(QImageIOHandler::Quality, d->quality);
// read the image
if (!d->handler->read(image)) {
d->imageReaderError = InvalidDataError;
d->errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unable to read image data"));
return false;
}
// provide default implementations for any unsupported image
// options
if (d->handler->supportsOption(QImageIOHandler::ClipRect) && !d->clipRect.isNull()) {
if (d->handler->supportsOption(QImageIOHandler::ScaledSize) && d->scaledSize.isValid()) {
if (d->handler->supportsOption(QImageIOHandler::ScaledClipRect) && !d->scaledClipRect.isNull()) {
// all features are supported by the handler; nothing to do.
} else {
// the image is already scaled, so apply scaled clipping.
if (!d->scaledClipRect.isNull())
*image = image->copy(d->scaledClipRect);
}
} else {
if (d->handler->supportsOption(QImageIOHandler::ScaledClipRect) && !d->scaledClipRect.isNull()) {
// supports scaled clipping but not scaling, most
// likely a broken handler.
} else {
if (d->scaledSize.isValid()) {
*image = image->scaled(d->scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
if (d->scaledClipRect.isValid()) {
*image = image->copy(d->scaledClipRect);
}
}
}
} else {
if (d->handler->supportsOption(QImageIOHandler::ScaledSize) && d->scaledSize.isValid()) {
// in this case, there's nothing we can do. if the
// plugin supports scaled size but not ClipRect, then
// we have to ignore ClipRect."
if (d->handler->supportsOption(QImageIOHandler::ScaledClipRect) && !d->scaledClipRect.isNull()) {
// nothing to do (ClipRect is ignored!)
} else {
// provide all workarounds.
if (d->scaledClipRect.isValid()) {
*image = image->copy(d->scaledClipRect);
}
}
} else {
if (d->handler->supportsOption(QImageIOHandler::ScaledClipRect) && !d->scaledClipRect.isNull()) {
// this makes no sense; a handler that supports
// ScaledClipRect but not ScaledSize is broken, and we
// can't work around it.
} else {
// provide all workarounds.
if (d->clipRect.isValid())
*image = image->copy(d->clipRect);
if (d->scaledSize.isValid())
*image = image->scaled(d->scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (d->scaledClipRect.isValid())
*image = image->copy(d->scaledClipRect);
}
}
}
return true;
}
找到核心代码了就是看不懂 到底怎么回事
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。