mirror of
https://github.com/status-im/qzxing.git
synced 2025-01-11 19:44:36 +00:00
added custom function for calculating the grayscale value of a pixel.
This commit is contained in:
parent
41ebf93087
commit
dfde91a225
@ -50,8 +50,8 @@ QImage* CameraImageWrapper::grayScaleImage(const QImage *origin)
|
||||
for(int j=0; j<origin->height(); j++)
|
||||
{
|
||||
QRgb pixel = origin->pixel(QPoint(i,j));
|
||||
QRgb pix = (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3;
|
||||
//qGray(origin->pixel(QPoint(i,j)));
|
||||
QRgb pix = gray(qRed(pixel),qGreen(pixel),qBlue(pixel));
|
||||
//gray(origin->pixel(QPoint(i,j)));
|
||||
tmp->setPixel(i,j, qRgb(pix ,pix,pix));
|
||||
}
|
||||
}
|
||||
@ -157,31 +157,6 @@ ArrayRef<char> CameraImageWrapper::getMatrixP() const
|
||||
return arr;
|
||||
}
|
||||
|
||||
//bool CameraImageWrapper::isCropSupported() const
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
//Ref<LuminanceSource> CameraImageWrapper::crop(int left, int top, int width, int height) const
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//bool CameraImageWrapper::isRotateSupported() const
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
//Ref<LuminanceSource> CameraImageWrapper::invert() const
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//Ref<LuminanceSource> CameraImageWrapper::rotateCounterClockwise() const
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
QImage *CameraImageWrapper::sharpen(const QImage *origin)
|
||||
{
|
||||
QImage * newImage = new QImage(* origin);
|
||||
@ -220,3 +195,9 @@ QImage *CameraImageWrapper::sharpen(const QImage *origin)
|
||||
}
|
||||
return newImage;
|
||||
}
|
||||
|
||||
unsigned int CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b)
|
||||
{
|
||||
//values based on http://entropymine.com/imageworsener/grayscale/
|
||||
return (r*7+g*23+b*2)/32;
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ private:
|
||||
|
||||
QImage* sharpen(const QImage *origin);
|
||||
|
||||
unsigned int gray(unsigned int r, unsigned int g, unsigned int b);
|
||||
|
||||
QImage* image;
|
||||
Ref<GreyscaleLuminanceSource> delegate;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user