How to clear or erase, drawn color from image
I am filling color on top of image. But this function will be called 10 sec once to fill different color.
My issue is, Since previously filled color still exists on the image. The colors are overlapping every time.
I want to clear the filled color before fill again.
Code:
class GraphicsView_Layout
: public QWidget {
Q_OBJECT
};
{
ui.setupUi(this);
mfloorImg
=new QImage("./img.jpg");
}
//This function will be called every 10 sec once to fill different color.
void QWidget::Fill_Area_With_Color(float* nPmv
) {
//Here I want to clear the previously drawn color
//Draw color
int nPos_X=0;
int nPos_Y=0;
for(int i=0;i<g_area_count;i++)
{
int nblock_count=mBlock_Count[i];
areaColor=Get_Area_Color(nPmv[i]);
for(int j=0;j<nblock_count;j++)
{
nPos_X=mPtrCoordinates[i][j][0];
nPos_Y=mPtrCoordinates[i][j][1];
//painter.fillRect(QRect(nPos_X,nPos_Y,28,24),QBrush(areaColor));
painter.
fillRect(QRect(nPos_X,nPos_Y,
28,
24),
QBrush(areaColor
));
}
}
m_gviewBasic->addImage(mfloorImg);
emit Show_GraphicsView_Layout(true);
QObject::connect(m_gviewBasic,
SIGNAL(Mouse_Left_Button_Clicked
(int,
int)),
this,
SLOT(Mouse_Clicked
(int,
int)));
}
Re: How to clear or erase, drawn color from image
You write into the image, so obviously the pixels in that image change.
You can either load the image again, or keep the original image and always paint into a copy.
Cheers,
_