颜色具有QImage
rgba组件的值,我们在QImage
中标记此颜色并读取 m_color(QColor(0,127,0,100);
m_pen.setColor(m_color); //set Qpen color
m_painter.setPen(m_pen);
m_painter.setCompositionMode(QPainter::CompositionMode_Source);
painter->drawPixmap(Qpoint(0,0),*m_Pixmap);//m_Pixmap is QPixmap
m_painter.drawline(initialpoint,finalpoint);// draw line over transparent pixmap item
QImage img =m_Pixmap->toImage;
for (int i=0;i<img.height();i++) //col
{
for(int j=0;j<img.width();j++) //row
{
qDebug()<<qGreen(img.pixel(j,i)); /// it return 50 during traverse painter line else give 0/// but it should return 127 as red component is 127
///code
}
if(QColor(img.pixel(j,i)==m_color)/// its never true// it should true during traverse the line draw by painter on pixmap
///code
}
}
}
的像素的红色,它给出不同的值,即它给出红色分量= 50。
码
var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {},
$checkboxes = $("#checkbox-container :checkbox");
$checkboxes.on("change", function() {
$checkboxes.each(function() {
checkboxValues[this.id] = this.checked;
});
localStorage.setItem("checkboxValues", JSON.stringify(checkboxValues));
});
// On page load
$.each(checkboxValues, function(key, value) {
$("#" + key).prop('checked', value);
if(value){
$("#" + key).parent('label').css('background', 'yellow');
}
});
没有任何东西设置为画家它直接绘制线...当m_color具有没有alpha值的颜色或者如果alpha为255时,颜色匹配为真
答案 0 :(得分:0)
根据Qt4文档,m_Pixmap-&gt; toImage将返回没有Alpha通道的RGB32图像。 Dataformat是0xFFRRGGBB。所以Alpha总是255。
http://doc.qt.io/qt-4.8/qpixmap.html#toImage
将图像转换为QPixmap时,请尝试保留QImage。