Perceptual Color

interlacingpass.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef InterlacingPass_H
5#define InterlacingPass_H
6
7#include "helpermath.h"
8#include <qsize.h>
9
10namespace PerceptualColor
11{
12/** @internal
13 *
14 * @brief Describes an interlacing pass.
15 *
16 * Objects of this class provide information about interlacing passes
17 * for <a href="https://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>-like
18 * interlacing.
19 *
20 * To do <a href="https://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>
21 * interlacing, construct an object of this class with a <tt>passCount</tt>
22 * of <tt>7</tt>. Do the first pass using the values provided
23 * by this object. Then, call @ref switchToNextPass to update the
24 * values and do the next interlacing pass.
25 *
26 * The pixels in your image are divided in lines, who in turn are subdivided
27 * in columns. Within each interlacing pass, go through every
28 * @ref lineFrequency th line, starting with the line at @ref lineOffset.
29 * Within each line, go through every @ref columnFrequency th column, starting
30 * with @ref columnOffset. Draw a rectangle with the size @ref rectangleSize
31 * who’s top-left pixel is at the current column and line.
32 *
33 * @note As this is just an internal class which is not part of the public API,
34 * there is direct access to its data members for simplicity reasons. However,
35 * it is not allowed to change them directly! Use them read-only. */
36class InterlacingPass final
37{
38public:
39 /** @brief Constructor
40 *
41 * Constructs an object for a new interlacing cycle.
42 *
43 * @tparam passCount Number of passes within this interlacing
44 * cycle. This MUST be a positive odd number. Use <tt>7</tt>
45 * for <a href="https://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>
46 * interlacing, or any other positive odd number for
47 * <a href="https://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>-like
48 * interlacing, but with a different number of steps.
49 *
50 * @returns A corresponding object. */
51 template<int passCount>
52 static InterlacingPass make()
53 {
54 static_assert(passCount > 0, "passCount must be positive.");
55 static_assert(isOdd(passCount), "passCount must be odd.");
56 return InterlacingPass(passCount);
57 }
58
59 void switchToNextPass();
60
61 /** @brief Size of the rectangles drawn during this pass. */
62 QSize rectangleSize;
63 /** @brief Draw a rectangle every umpteenth column. */
64 int columnFrequency;
65 /** @brief First column on a given line to draw a rectangle. */
66 int columnOffset;
67 /** @brief Draw a rectangle every umpteenth line. */
68 int lineFrequency;
69 /** @brief First line to process. */
70 int lineOffset;
71 /** @brief Pass countdown.
72 *
73 * Inverse counting of the interlacing passes.
74 *
75 * Example for
76 * <a href="https://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>:
77 *
78 * | Pass | @ref countdown |
79 * | :---------- | :------------: |
80 * | 1st | 7 |
81 * | 2nd | 6 |
82 * | 3rd | 5 |
83 * | 4th | 4 |
84 * | 5th | 3 |
85 * | 6th | 2 |
86 * | 7th (last) | 1 | */
87 int countdown;
88
89private:
90 explicit InterlacingPass(const int passCount);
91
92 /** @internal @brief Only for unit tests. */
93 friend class TestInterlacingPass;
94};
95
96} // namespace PerceptualColor
97
98#endif // InterlacingPass_H
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:36 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.