有点笨。static inline QImage changeImageAlphaByDot(const QImage &img, int alpha)
{
QRgb tmpRgb;
// check alpha
if (alpha < 0)
{
alpha = 0;
}
if (alpha > 255)
{
alpha = 255;
}
QImage tmpImg = img;
if (!tmpImg.hasAlphaChannel())
{
tmpImg.setAlphaChannel(tmpImg);
}
// m_qImage[3].load("images/b1.bmp");
// m_pqImage[0] = new QImage(m_qImage[3].bits(), m_qImage[3].width(), m_qImage[3].height(), QImage::Format_ARGB32);
// tmpImg.
for (short i = 0; i < tmpImg.height(); i++)
{
for (short j = 0; j < tmpImg.width(); j++)
{
tmpRgb = tmpImg.pixel(j, i);
tmpImg.setPixel(j, i, qRgba(qRed(tmpRgb), qGreen(tmpRgb), qBlue(tmpRgb), alpha));
}
}
return tmpImg;
}
不知QIMage有没有跟简单的方法