Coverage Report

Created: 2023-09-25 06:41

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