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 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 copy()42 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>). test(int x,int y,unsigned char value)46 int test(int x, int y, unsigned char value) 47 { 48 int xx, yy; 49 if (mat == nullptr) 50 createMatrix(); 51 xx = x & sizeM1; 52 yy = y & sizeM1; 53 return value < mat[(yy << log2Size) + xx] ? 0 : 1; 54 } 55 56 // Returns true if value is above the white threshold or below the 57 // black threshold, i.e., if the corresponding halftone will be 58 // solid white or black. isStatic(unsigned char value)59 bool isStatic(unsigned char value) 60 { 61 if (mat == nullptr) 62 createMatrix(); 63 return value < minVal || value >= maxVal; 64 } 65 66 private: 67 void createMatrix(); 68 69 void buildDispersedMatrix(int i, int j, int val, int delta, int offset); 70 void buildClusteredMatrix(); 71 int distance(int x0, int y0, int x1, int y1); 72 void buildSCDMatrix(int r); 73 74 const SplashScreenParams *screenParams; // params to create the other members 75 unsigned char *mat; // threshold matrix 76 int size; // size of the threshold matrix 77 int sizeM1; // size - 1 78 int log2Size; // log2(size) 79 unsigned char minVal; // any pixel value below minVal generates 80 // solid black 81 unsigned char maxVal; // any pixel value above maxVal generates 82 // solid white 83 }; 84 85 #endif 86