{
pen = rgb;
for (penpixel = 0;
- penpixel<img.numColors()-1 && img.color(penpixel)!=pen.rgb();
+ penpixel<img.numColors()-1 && (img.color(penpixel)&0xffffff)!=(pen.rgb()&0xffffff);
penpixel++)
continue;
+qDebug("penpixel=%d, pen=%x",penpixel,pen.rgb());
}
void TrivialTileEditor::setImage( const QImage& i )
void TrivialTileEditor::mousePressEvent(QMouseEvent* e)
{
QPoint p = imagePoint(e->pos());
+ if ( !img.rect().contains(p) )
+ return;
uchar& pixel = img.scanLine(p.y())[p.x()];
if ( e->button() == LeftButton ) {
pixel = penpixel;
emit pick( img.color(pixel) );
} else if ( e->button() == MidButton ) {
QPainter painter(this);
- fill(painter,p,pixel);
+ if ( pixel != penpixel )
+ fill(painter,p,pixel);
}
}
void TrivialTileEditor::mouseMoveEvent(QMouseEvent* e)
{
QPoint p = imagePoint(e->pos());
+ if ( !img.rect().contains(p) )
+ return;
uchar& pixel = img.scanLine(p.y())[p.x()];
pixel = penpixel;
QPainter painter(this);