/src/poppler/splash/SplashScreen.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // SplashScreen.h |
4 | | // |
5 | | //======================================================================== |
6 | | |
7 | | //======================================================================== |
8 | | // |
9 | | // Modified under the Poppler project - http://poppler.freedesktop.org |
10 | | // |
11 | | // All changes made under the Poppler project to this file are licensed |
12 | | // under GPL version 2 or later |
13 | | // |
14 | | // Copyright (C) 2009, 2018, 2020, 2021, 2025 Albert Astals Cid <aacid@kde.org> |
15 | | // |
16 | | // To see a description of the changes please see the Changelog file that |
17 | | // came with your tarball or type make ChangeLog if you are building from git |
18 | | // |
19 | | //======================================================================== |
20 | | |
21 | | #ifndef SPLASHSCREEN_H |
22 | | #define SPLASHSCREEN_H |
23 | | |
24 | | #include "SplashTypes.h" |
25 | | |
26 | | #include <cstdlib> |
27 | | |
28 | | //------------------------------------------------------------------------ |
29 | | // SplashScreen |
30 | | //------------------------------------------------------------------------ |
31 | | |
32 | | class SplashScreen |
33 | | { |
34 | | public: |
35 | | explicit SplashScreen(const SplashScreenParams *params); |
36 | | explicit SplashScreen(const SplashScreen *screen); |
37 | | ~SplashScreen(); |
38 | | |
39 | | SplashScreen(const SplashScreen &) = delete; |
40 | | SplashScreen &operator=(const SplashScreen &) = delete; |
41 | | |
42 | 4.29M | SplashScreen *copy() const { return new SplashScreen(this); } |
43 | | |
44 | | // Return the computed pixel value (0=black, 1=white) for the gray |
45 | | // level <value> at (<x>, <y>). |
46 | | int test(int x, int y, unsigned char value) |
47 | 7.44M | { |
48 | 7.44M | int xx, yy; |
49 | 7.44M | if (mat == nullptr) { |
50 | 162 | createMatrix(); |
51 | 162 | } |
52 | 7.44M | xx = x & sizeM1; |
53 | 7.44M | yy = y & sizeM1; |
54 | 7.44M | return value < mat[(yy << log2Size) + xx] ? 0 : 1; |
55 | 7.44M | } |
56 | | |
57 | | private: |
58 | | void createMatrix(); |
59 | | |
60 | | void buildDispersedMatrix(int i, int j, int val, int delta, int offset); |
61 | | void buildClusteredMatrix(); |
62 | | int distance(int x0, int y0, int x1, int y1); |
63 | | void buildSCDMatrix(int r); |
64 | | |
65 | | const SplashScreenParams *screenParams; // params to create the other members |
66 | | unsigned char *mat; // threshold matrix |
67 | | int size; // size of the threshold matrix |
68 | | int sizeM1; // size - 1 |
69 | | int log2Size; // log2(size) |
70 | | }; |
71 | | |
72 | | #endif |