Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qimagescale_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QIMAGESCALE_P_H
4#define QIMAGESCALE_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <qimage.h>
18#include <private/qtguiglobal_p.h>
19
20#if QT_CONFIG(qtgui_threadpool)
21#include <qthreadpool.h>
22#include <private/qguiapplication_p.h>
23#include <private/qlatch_p.h>
24#include <private/qthreadpool_p.h>
25#endif
26
28
29/*
30 This version accepts only supported formats.
31*/
32QImage qSmoothScaleImage(const QImage &img, int w, int h);
33
34namespace QImageScale {
36 int *xpoints{nullptr};
37 const unsigned int **ypoints{nullptr};
38 int *xapoints{nullptr};
39 int *yapoints{nullptr};
40 int xup_yup{0};
41 int sh = 0;
42 int sw = 0;
43 };
44
45 template<typename T>
46 void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection)
47 {
48#if QT_CONFIG(qtgui_threadpool)
49 int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
50 segments = std::min(segments, dh);
51 QThreadPool *threadPool = QGuiApplicationPrivate::qtGuiThreadPool();
52 if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
53 QLatch latch(segments);
54 int y = 0;
55 for (int i = 0; i < segments; ++i) {
56 int yn = (dh - y) / (segments - i);
57 threadPool->start([&, y, yn]() {
58 scaleSection(y, y + yn);
59 latch.countDown();
60 });
61 y += yn;
62 }
63 latch.wait();
64 return;
65 }
66#else
67 Q_UNUSED(isi);
68#endif
69 scaleSection(0, dh);
70 }
71}
72
73QT_END_NAMESPACE
74
75#endif
void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection)
Combined button and popup list for selecting options.
const unsigned int ** ypoints