Removed c-like cast

master
Unknown 2017-03-03 10:57:44 +01:00
parent d328314a74
commit d176970462
1 changed files with 13 additions and 16 deletions

View File

@ -37,29 +37,26 @@ QColor MakeColors::processImage(QString path)
QColor color; QColor color;
//convert to RGB32 format //convert to RGB32 format
img = img.convertToFormat(QImage::Format_ARGB32); img = img.convertToFormat(QImage::Format_ARGB32);
int w = img.width(); const int width = img.width();
int h = img.height(); const int height = img.height();
long r,g,b; long r = 0;
r=g=b=0; long g = 0;
int counter =0; long b = 0;
for(int i = 0; i<h; i++)
int counter = 0;
for (int i = 0; i<height; i++)
{ {
//QRgb *line = static_cast<QRgb*>img.constScanLine(i);
//Dont access rowData directly! it depends on platform. always use QRgb() //Dont access rowData directly! it depends on platform. always use QRgb()
QRgb *rowData = (QRgb*)img.constScanLine(i); const QRgb *rowData = reinterpret_cast<const QRgb *>(img.constScanLine(i));
for(int j = 0;j<w; j++){ for (int j = 0; j < width; j++) {
QRgb pixelData = rowData[j]; QRgb pixelData = rowData[j];
if (qAlpha(pixelData) < 128) if (qAlpha(pixelData) < 128)
continue; continue;
int red = qRed(pixelData); r += qRed(pixelData);
int gre = qGreen(pixelData); g += qGreen(pixelData);
int blu = qBlue(pixelData); b += qBlue(pixelData);
r+=red;
g+=gre;
b+=blu;
counter++; counter++;