PDA

View Full Version : 8bit greyscale raw picture find painted area



dazedly
16th April 2012, 12:20
I want to find and cut out the painted area (painted means: not transparent.). Do you got any Ideas how to do that?
Data Informations:
unsigned char array* imageData; // (each entry = grey value of pixel)
int imageHeight;
int imageWidth;
int imageSize;
Example Code:


QPixmap img(imageWidth , imageHeight);
img.fill(Qt::transparent);
QPainter paint(&img);
paint.setCompositionMode(QPainter::CompositionMode _Source);

int currentPos;


while(currentpos < imageDataSize)
{
int x = imageDataSize % imageWidth;
int y = imageDataSize / imageWidth+1;
int greyVal = imageData[currentPos];

paint.setPen(QColor(greyVal,greyVal,greyVal);
if(hmm < 160)
{
paint.drawPoint(x,y);
} else {
paint.save();
paint.setOpacity(0.0);
paint.setPen(QColor(255,255,255,255));
paint.drawPoint(x,y);
paint.restore();

}
currentPos++;
}

dennis81
17th April 2012, 10:00
Detect the MinimumX, MinimumY and MaximumX, MaximumY non transparent Pixels and create a QRect.
There is copyRect method for QImage...