Fix some crashes in unused tile editor.
tileedit is the program I use to edit tile files (directly).
This commit is contained in:
@@ -180,9 +180,10 @@ void TrivialTileEditor::setColor( QRgb rgb )
|
||||
{
|
||||
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 )
|
||||
@@ -217,6 +218,8 @@ void TrivialTileEditor::paintPoint(QPainter& painter, QPoint p)
|
||||
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;
|
||||
@@ -226,7 +229,8 @@ void TrivialTileEditor::mousePressEvent(QMouseEvent* e)
|
||||
emit pick( img.color(pixel) );
|
||||
} else if ( e->button() == MidButton ) {
|
||||
QPainter painter(this);
|
||||
fill(painter,p,pixel);
|
||||
if ( pixel != penpixel )
|
||||
fill(painter,p,pixel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +257,8 @@ void TrivialTileEditor::mouseReleaseEvent(QMouseEvent* e)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user