Revamp Queued Custom Type Ex: Add const when applicable
Task-number: QTBUG-117147 Pick-to: 6.5 Change-Id: I2fe342fa585f8c1203fa64d2a9ceabc07070cc77 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 34ff72d0ba5284ff117ee4ae7f04072b51c85315) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d02e9b3150
commit
a1098f4462
@ -48,8 +48,8 @@ QImage createImage(int width, int height)
|
|||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int starWidth = image.width()/3;
|
const int starWidth = image.width()/3;
|
||||||
int starHeight = image.height()/3;
|
const int starHeight = image.height()/3;
|
||||||
|
|
||||||
QRect rect(x, y, starWidth, starHeight);
|
QRect rect(x, y, starWidth, starHeight);
|
||||||
|
|
||||||
|
@ -35,21 +35,21 @@ void RenderThread::processImage(const QImage &image)
|
|||||||
|
|
||||||
void RenderThread::run()
|
void RenderThread::run()
|
||||||
{
|
{
|
||||||
int size = qMax(m_image.width()/20, m_image.height()/20);
|
const int size = qMax(m_image.width()/20, m_image.height()/20);
|
||||||
for (int s = size; s > 0; --s) {
|
for (int s = size; s > 0; --s) {
|
||||||
for (int c = 0; c < 400; ++c) {
|
for (int c = 0; c < 400; ++c) {
|
||||||
//![processing the image (start)]
|
//![processing the image (start)]
|
||||||
int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
|
const int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
|
||||||
int x2 = qMin(x1 + s/2 + 1, m_image.width());
|
const int x2 = qMin(x1 + s/2 + 1, m_image.width());
|
||||||
int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
|
const int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
|
||||||
int y2 = qMin(y1 + s/2 + 1, m_image.height());
|
const int y2 = qMin(y1 + s/2 + 1, m_image.height());
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int red = 0;
|
int red = 0;
|
||||||
int green = 0;
|
int green = 0;
|
||||||
int blue = 0;
|
int blue = 0;
|
||||||
for (int i = y1; i < y2; ++i) {
|
for (int i = y1; i < y2; ++i) {
|
||||||
for (int j = x1; j < x2; ++j) {
|
for (int j = x1; j < x2; ++j) {
|
||||||
QRgb pixel = m_image.pixel(j, i);
|
const QRgb pixel = m_image.pixel(j, i);
|
||||||
red += qRed(pixel);
|
red += qRed(pixel);
|
||||||
green += qGreen(pixel);
|
green += qGreen(pixel);
|
||||||
blue += qBlue(pixel);
|
blue += qBlue(pixel);
|
||||||
@ -57,7 +57,7 @@ void RenderThread::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//![processing the image (finish)]
|
//![processing the image (finish)]
|
||||||
Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
|
const Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
|
||||||
QColor(red/n, green/n, blue/n));
|
QColor(red/n, green/n, blue/n));
|
||||||
emit sendBlock(block);
|
emit sendBlock(block);
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
|
@ -60,13 +60,13 @@ void Window::loadImage()
|
|||||||
if (format.toLower() == format)
|
if (format.toLower() == format)
|
||||||
formats.append(QLatin1String("*.") + QString::fromLatin1(format));
|
formats.append(QLatin1String("*.") + QString::fromLatin1(format));
|
||||||
|
|
||||||
QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
|
const QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
|
||||||
path, tr("Image files (%1)").arg(formats.join(' ')));
|
path, tr("Image files (%1)").arg(formats.join(' ')));
|
||||||
|
|
||||||
if (newPath.isEmpty())
|
if (newPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QImage image(newPath);
|
const QImage image(newPath);
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
loadImage(image);
|
loadImage(image);
|
||||||
path = newPath;
|
path = newPath;
|
||||||
@ -76,7 +76,7 @@ void Window::loadImage()
|
|||||||
void Window::loadImage(const QImage &image)
|
void Window::loadImage(const QImage &image)
|
||||||
{
|
{
|
||||||
QImage useImage;
|
QImage useImage;
|
||||||
QRect space = QGuiApplication::primaryScreen()->availableGeometry();
|
const QRect space = QGuiApplication::primaryScreen()->availableGeometry();
|
||||||
if (image.width() > 0.75*space.width() || image.height() > 0.75*space.height())
|
if (image.width() > 0.75*space.width() || image.height() > 0.75*space.height())
|
||||||
useImage = image.scaled(0.75*space.width(), 0.75*space.height(),
|
useImage = image.scaled(0.75*space.width(), 0.75*space.height(),
|
||||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user