fix zoom buttons in picedit

This commit is contained in:
Chris Cromer 2020-04-19 15:04:54 -04:00
parent 52a4b3fe32
commit 3db0d2f2e5
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
2 changed files with 20 additions and 11 deletions

View File

@ -606,6 +606,7 @@ void PicEdit::zoom_minus()
h = canvas->cur_h+4;
canvas->resizeContents(w,h);
}
canvas->update();
}
@ -620,6 +621,7 @@ void PicEdit::zoom_plus()
h = canvas->cur_h+4;
canvas->resizeContents(w,h);
}
canvas->update();
}
@ -902,7 +904,7 @@ void PCanvas::setPixsize(int s)
pixmap.resize(cur_w,cur_h);
QPainter p(&pixmap);
p.eraseRect(0,0,cur_w,cur_h);
update();
updatePainter(&p);
}
//*********************************************
@ -984,11 +986,17 @@ void PCanvas::drawContents(QPainter* p,int ,int ,int ,int )
}
//*********************************************
void PCanvas::update()
{
QPainter p(&pixmap);
updatePainter(&p);
}
//*********************************************
void PCanvas::updatePainter(QPainter *p)
{
//QPainter p(&pixmap);
int x,y;
byte c;
byte *data;
@ -1000,11 +1008,11 @@ void PCanvas::update()
for(x=0;x<MAX_W;x+=2){
c=data[y*MAX_W+x];
if((pic&&c==15)||(!pic&&c==4)){ //draw background instead of "empty" areas
p.fillRect(x*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x,y)));
p.fillRect((x+1)*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x+1,y)));
p->fillRect(x*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x,y)));
p->fillRect((x+1)*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x+1,y)));
}
else{
p.fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[c]);
p->fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[c]);
}
}
}
@ -1012,7 +1020,7 @@ void PCanvas::update()
else{
for(y=0;y<MAX_HH;y++){
for(x=0;x<MAX_W;x+=2){
p.fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[data[y*MAX_W+x]]);
p->fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[data[y*MAX_W+x]]);
}
}
}
@ -1030,11 +1038,11 @@ void PCanvas::update()
for(y=step*3;y<MAX_HH*pixsize;y+=step){
//pen.setBrush(QColor(255, 0, 0, 127));
pen.setBrush(egacolor[i++]);
p.setPen(pen);
p.drawLine(0,y,MAX_W*pixsize,y);
p->setPen(pen);
p->drawLine(0,y,MAX_W*pixsize,y);
pen.setBrush(QColor(0, 0, 0, 127));
p.setPen(pen);
p.drawLine(0,y+1,MAX_W*pixsize,y+1);
p->setPen(pen);
p->drawLine(0,y+1,MAX_W*pixsize,y+1);
}
}

View File

@ -80,6 +80,7 @@ public:
void load_bg(char *filename);
void draw(int ResNum);
void update();
void updatePainter(QPainter *p);
void setSize(int w,int h);
void setPixsize(int pixsize);
protected: