SplashTypes.h 6.51 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6
//========================================================================
//
// SplashTypes.h
//
//========================================================================

7 8 9 10
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
11 12 13
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
Albert Astals Cid's avatar
Albert Astals Cid committed
14
// Copyright (C) 2006, 2010, 2019, 2020 Albert Astals Cid <aacid@kde.org>
15
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
16
// Copyright (C) 2009, 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
Stefan Thomas's avatar
Stefan Thomas committed
17
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
18
// Copyright (C) 2010 William Bader <williambader@hotmail.com>
19
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
20
// Copyright (C) 2018 Stefan Brüns <stefan.bruens@rwth-aachen.de>
21 22 23 24 25 26
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

Kristian Høgsberg's avatar
Kristian Høgsberg committed
27 28 29
#ifndef SPLASHTYPES_H
#define SPLASHTYPES_H

Albert Astals Cid's avatar
Albert Astals Cid committed
30 31
#include <cstddef>

Kristian Høgsberg's avatar
Kristian Høgsberg committed
32 33 34 35
//------------------------------------------------------------------------
// coordinates
//------------------------------------------------------------------------

Adrian Bunk's avatar
Adrian Bunk committed
36
#if defined(USE_FLOAT)
37
typedef float SplashCoord;
38
#else
Kristian Høgsberg's avatar
Kristian Høgsberg committed
39
typedef double SplashCoord;
40
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
41

42 43 44 45 46 47
//------------------------------------------------------------------------
// antialiasing
//------------------------------------------------------------------------

#define splashAASize 4

48 49 50 51
#ifndef SPOT_NCOMPS
#define SPOT_NCOMPS 4
#endif

Kristian Høgsberg's avatar
Kristian Høgsberg committed
52 53 54 55 56
//------------------------------------------------------------------------
// colors
//------------------------------------------------------------------------

enum SplashColorMode {
57 58 59 60 61 62 63
  splashModeMono1,		// 1 bit per component, 8 pixels per byte,
				//   MSbit is on the left
  splashModeMono8,		// 1 byte per component, 1 byte per pixel
  splashModeRGB8,		// 1 byte per component, 3 bytes per pixel:
				//   RGBRGB...
  splashModeBGR8,		// 1 byte per component, 3 bytes per pixel:
				//   BGRBGR...
Albert Astals Cid's avatar
Albert Astals Cid committed
64
  splashModeXBGR8,		// 1 byte per component, 4 bytes per pixel:
65
				//   XBGRXBGR...
66
  splashModeCMYK8,	// 1 byte per component, 4 bytes per pixel:
67
				//   CMYKCMYK...
68 69 70
  splashModeDeviceN8		// 1 byte per component, 
                        // 4 bytes + n bytes spot colors per pixel:
				                // CMYKSSSSCMYKSSSS...
Kristian Høgsberg's avatar
Kristian Høgsberg committed
71 72
};

73 74 75 76 77 78
enum SplashThinLineMode {
  splashThinLineDefault,  // if SA on: draw solid if requested line width, transformed into 
                          // device space, is less than half a pixel and a shaped line else
  splashThinLineSolid,     // draw line solid at least with 1 pixel 
  splashThinLineShape     // draw line shaped at least with 1 pixel
};
79 80 81 82
// number of components in each color mode
// (defined in SplashState.cc)
extern int splashColorModeNComps[];

Kristian Høgsberg's avatar
Kristian Høgsberg committed
83
// max number of components in any SplashColor
Albert Astals Cid's avatar
Albert Astals Cid committed
84
constexpr std::size_t splashMaxColorComps = SPOT_NCOMPS+4;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
85

86 87
typedef unsigned char SplashColor[splashMaxColorComps];
typedef unsigned char *SplashColorPtr;
Albert Astals Cid's avatar
Albert Astals Cid committed
88
typedef const unsigned char *SplashColorConstPtr;
89 90

// RGB8
91 92 93
static inline unsigned char splashRGB8R(SplashColorPtr rgb8) { return rgb8[0]; }
static inline unsigned char splashRGB8G(SplashColorPtr rgb8) { return rgb8[1]; }
static inline unsigned char splashRGB8B(SplashColorPtr rgb8) { return rgb8[2]; }
94 95

// BGR8
96 97 98
static inline unsigned char splashBGR8R(SplashColorPtr bgr8) { return bgr8[2]; }
static inline unsigned char splashBGR8G(SplashColorPtr bgr8) { return bgr8[1]; }
static inline unsigned char splashBGR8B(SplashColorPtr bgr8) { return bgr8[0]; }
99 100

// CMYK8
101 102 103 104
static inline unsigned char splashCMYK8C(SplashColorPtr cmyk8) { return cmyk8[0]; }
static inline unsigned char splashCMYK8M(SplashColorPtr cmyk8) { return cmyk8[1]; }
static inline unsigned char splashCMYK8Y(SplashColorPtr cmyk8) { return cmyk8[2]; }
static inline unsigned char splashCMYK8K(SplashColorPtr cmyk8) { return cmyk8[3]; }
105 106

// DEVICEN8
107 108 109 110 111
static inline unsigned char splashDeviceN8C(SplashColorPtr deviceN8) { return deviceN8[0]; }
static inline unsigned char splashDeviceN8M(SplashColorPtr deviceN8) { return deviceN8[1]; }
static inline unsigned char splashDeviceN8Y(SplashColorPtr deviceN8) { return deviceN8[2]; }
static inline unsigned char splashDeviceN8K(SplashColorPtr deviceN8) { return deviceN8[3]; }
static inline unsigned char splashDeviceN8S(SplashColorPtr deviceN8, int nSpot) { return deviceN8[4 + nSpot]; }
112

113 114 115 116 117
static inline void splashClearColor(SplashColorPtr dest) {
  dest[0] = 0;
  dest[1] = 0;
  dest[2] = 0;
  dest[3] = 0;
118
  for (int i = 4; i < SPOT_NCOMPS + 4; i++)
119
    dest[i] = 0;
120 121
}

Albert Astals Cid's avatar
Albert Astals Cid committed
122
static inline void splashColorCopy(SplashColorPtr dest, SplashColorConstPtr src) {
123 124 125
  dest[0] = src[0];
  dest[1] = src[1];
  dest[2] = src[2];
126
  dest[3] = src[3];
127
  for (int i = 4; i < SPOT_NCOMPS + 4; i++)
128
    dest[i] = src[i];
129 130
}

131 132 133 134 135 136 137
static inline bool splashColorEqual(SplashColorConstPtr dest, SplashColorConstPtr src) {
  for (int i = 0; i < SPOT_NCOMPS + 4; i++)
    if (dest[i] != src[i])
        return false;
  return true;
}

Albert Astals Cid's avatar
Albert Astals Cid committed
138
static inline void splashColorXor(SplashColorPtr dest, SplashColorConstPtr src) {
139 140 141
  dest[0] ^= src[0];
  dest[1] ^= src[1];
  dest[2] ^= src[2];
142
  dest[3] ^= src[3];
143
  for (int i = 4; i < SPOT_NCOMPS + 4; i++)
144
    dest[i] ^= src[i];
145 146 147 148 149 150 151 152
}

//------------------------------------------------------------------------
// blend functions
//------------------------------------------------------------------------

typedef void (*SplashBlendFunc)(SplashColorPtr src, SplashColorPtr dest,
				SplashColorPtr blend, SplashColorMode cm);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
153

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
//------------------------------------------------------------------------
// screen parameters
//------------------------------------------------------------------------

enum SplashScreenType {
  splashScreenDispersed,
  splashScreenClustered,
  splashScreenStochasticClustered
};

struct SplashScreenParams {
  SplashScreenType type;
  int size;
  int dotRadius;
  SplashCoord gamma;
  SplashCoord blackThreshold;
  SplashCoord whiteThreshold;
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
173 174 175 176 177 178
//------------------------------------------------------------------------
// error results
//------------------------------------------------------------------------

typedef int SplashError;

Stefan Thomas's avatar
Stefan Thomas committed
179 180 181 182 183 184 185

//------------------------------------------------------------------------
// image file formats
//------------------------------------------------------------------------

enum SplashImageFileFormat {
  splashFormatJpeg,
186
  splashFormatPng,
Thomas Freitag's avatar
Thomas Freitag committed
187 188
  splashFormatTiff,
  splashFormatJpegCMYK
Stefan Thomas's avatar
Stefan Thomas committed
189 190
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
191
#endif