| 1 |
//======================================================================== |
| 2 |
// |
| 3 |
// SplashScreen.h |
| 4 |
// |
| 5 |
// Copyright 2003-2013 Glyph & Cog, LLC |
| 6 |
// |
| 7 |
//======================================================================== |
| 8 |
|
| 9 |
#ifndef SPLASHSCREEN_H |
| 10 |
#define SPLASHSCREEN_H |
| 11 |
|
| 12 |
#include <aconf.h> |
| 13 |
|
| 14 |
#include "SplashTypes.h" |
| 15 |
|
| 16 |
//------------------------------------------------------------------------ |
| 17 |
// SplashScreen |
| 18 |
//------------------------------------------------------------------------ |
| 19 |
|
| 20 |
typedef Guchar *SplashScreenCursor; |
| 21 |
|
| 22 |
class SplashScreen { |
| 23 |
public: |
| 24 |
|
| 25 |
SplashScreen(SplashScreenParams *params); |
| 26 |
SplashScreen(SplashScreen *screen); |
| 27 |
~SplashScreen(); |
| 28 |
|
| 29 |
SplashScreen *copy() { return new SplashScreen(this); } |
| 30 |
|
| 31 |
// Return the computed pixel value (0=black, 1=white) for the gray |
| 32 |
// level <value> at (<x>, <y>). |
| 33 |
int test(int x, int y, Guchar value) { |
| 34 |
int xx, yy; |
| 35 |
xx = x & sizeM1; |
| 36 |
yy = y & sizeM1; |
| 37 |
return value < mat[(yy << log2Size) + xx] ? 0 : 1; |
| 38 |
} |
| 39 |
|
| 40 |
// To do a series of tests with the same y value, call |
| 41 |
// getTestCursor(y), and then call testWithCursor(cursor, x, value) |
| 42 |
// for each x. |
| 43 |
SplashScreenCursor getTestCursor(int y) { |
| 44 |
int yy; |
| 45 |
yy = y & sizeM1; |
| 46 |
return &mat[yy << log2Size]; |
| 47 |
} |
| 48 |
|
| 49 |
int testWithCursor(SplashScreenCursor cursor, int x, Guchar value) { |
| 50 |
int xx = x & sizeM1; |
| 51 |
return value >= cursor[xx]; |
| 52 |
} |
| 53 |
|
| 54 |
// Returns true if value is above the white threshold or below the |
| 55 |
// black threshold, i.e., if the corresponding halftone will be |
| 56 |
// solid white or black. |
| 57 |
GBool isStatic(Guchar value) { return value < minVal || value >= maxVal; } |
| 58 |
|
| 59 |
private: |
| 60 |
|
| 61 |
void buildDispersedMatrix(int i, int j, int val, |
| 62 |
int delta, int offset); |
| 63 |
void buildClusteredMatrix(); |
| 64 |
int distance(int x0, int y0, int x1, int y1); |
| 65 |
void buildSCDMatrix(int r); |
| 66 |
|
| 67 |
Guchar *mat; // threshold matrix |
| 68 |
int size; // size of the threshold matrix |
| 69 |
int sizeM1; // size - 1 |
| 70 |
int log2Size; // log2(size) |
| 71 |
Guchar minVal; // any pixel value below minVal generates |
| 72 |
// solid black |
| 73 |
Guchar maxVal; // any pixel value above maxVal generates |
| 74 |
// solid white |
| 75 |
}; |
| 76 |
|
| 77 |
#endif |