/usr/include/poppler/GfxState.h is in libpoppler-private-dev 0.48.0-2+deb9u2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 | //========================================================================
//
// GfxState.h
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009 Koji Otani <sho@bbr.jp>
// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
// Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com>
// Copyright (C) 2011-2014, 2016 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
// Copyright (C) 2015 Adrian Johnson <ajohnson@redneon.com>
//
// 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
//
//========================================================================
#ifndef GFXSTATE_H
#define GFXSTATE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "poppler-config.h"
#include "goo/gtypes.h"
#include "Object.h"
#include "Function.h"
#include <assert.h>
#include <map>
class Array;
class Gfx;
class GfxFont;
class PDFRectangle;
class GfxShading;
class PopplerCache;
class GooList;
class OutputDev;
class GfxState;
class GfxResources;
class Matrix {
public:
double m[6];
void init(double xx, double yx, double xy, double yy, double x0, double y0) {
m[0] = xx; m[1] = yx; m[2] = xy; m[3] = yy; m[4] = x0; m[5] = y0;
}
GBool invertTo(Matrix *other) const;
void translate(double tx, double ty);
void scale(double sx, double sy);
void transform(double x, double y, double *tx, double *ty) const;
double determinant() const { return m[0] * m[3] - m[1] * m[2]; }
double norm() const;
};
//------------------------------------------------------------------------
// GfxBlendMode
//------------------------------------------------------------------------
enum GfxBlendMode {
gfxBlendNormal,
gfxBlendMultiply,
gfxBlendScreen,
gfxBlendOverlay,
gfxBlendDarken,
gfxBlendLighten,
gfxBlendColorDodge,
gfxBlendColorBurn,
gfxBlendHardLight,
gfxBlendSoftLight,
gfxBlendDifference,
gfxBlendExclusion,
gfxBlendHue,
gfxBlendSaturation,
gfxBlendColor,
gfxBlendLuminosity
};
//------------------------------------------------------------------------
// GfxColorComp
//------------------------------------------------------------------------
// 16.16 fixed point color component
typedef int GfxColorComp;
#define gfxColorComp1 0x10000
static inline GfxColorComp dblToCol(double x) {
return (GfxColorComp)(x * gfxColorComp1);
}
static inline double colToDbl(GfxColorComp x) {
return (double)x / (double)gfxColorComp1;
}
static inline Guchar dblToByte(double x) {
return (x * 255.0);
}
static inline double byteToDbl(Guchar x) {
return (double)x / (double)255.0;
}
static inline GfxColorComp byteToCol(Guchar x) {
// (x / 255) << 16 = (0.0000000100000001... * x) << 16
// = ((x << 8) + (x) + (x >> 8) + ...) << 16
// = (x << 8) + (x) + (x >> 7)
// [for rounding]
return (GfxColorComp)((x << 8) + x + (x >> 7));
}
static inline Guchar colToByte(GfxColorComp x) {
// 255 * x + 0.5 = 256 * x - x + 0x8000
return (Guchar)(((x << 8) - x + 0x8000) >> 16);
}
//------------------------------------------------------------------------
// GfxColor
//------------------------------------------------------------------------
#define gfxColorMaxComps funcMaxOutputs
struct GfxColor {
GfxColorComp c[gfxColorMaxComps];
};
//------------------------------------------------------------------------
// GfxGray
//------------------------------------------------------------------------
typedef GfxColorComp GfxGray;
//------------------------------------------------------------------------
// GfxRGB
//------------------------------------------------------------------------
struct GfxRGB {
GfxColorComp r, g, b;
};
//------------------------------------------------------------------------
// GfxCMYK
//------------------------------------------------------------------------
struct GfxCMYK {
GfxColorComp c, m, y, k;
};
//------------------------------------------------------------------------
// GfxColorSpace
//------------------------------------------------------------------------
// NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames
// array defined in GfxState.cc must match this enum.
enum GfxColorSpaceMode {
csDeviceGray,
csCalGray,
csDeviceRGB,
csCalRGB,
csDeviceCMYK,
csLab,
csICCBased,
csIndexed,
csSeparation,
csDeviceN,
csPattern
};
// wrapper of cmsHTRANSFORM to copy
class GfxColorTransform {
public:
void doTransform(void *in, void *out, unsigned int size);
// transformA should be a cmsHTRANSFORM
GfxColorTransform(void *transformA, int cmsIntent, unsigned int inputPixelType, unsigned int transformPixelType);
~GfxColorTransform();
int getIntent() { return cmsIntent; }
int getInputPixelType() { return inputPixelType; }
int getTransformPixelType() { return transformPixelType; }
void ref();
unsigned int unref();
private:
GfxColorTransform() {}
void *transform;
unsigned int refCount;
int cmsIntent;
unsigned int inputPixelType;
unsigned int transformPixelType;
};
class GfxColorSpace {
public:
GfxColorSpace();
virtual ~GfxColorSpace();
virtual GfxColorSpace *copy() = 0;
virtual GfxColorSpaceMode getMode() = 0;
// Construct a color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion = 0);
// Convert to gray, RGB, or CMYK.
virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN) = 0;
virtual void getGrayLine(Guchar * /*in*/, Guchar * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getGrayLine this should not happen"); }
virtual void getRGBLine(Guchar * /*in*/, unsigned int * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (first variant) this should not happen"); }
virtual void getRGBLine(Guchar * /*in*/, Guchar * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (second variant) this should not happen"); }
virtual void getRGBXLine(Guchar * /*in*/, Guchar * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBXLine this should not happen"); }
virtual void getCMYKLine(Guchar * /*in*/, Guchar * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getCMYKLine this should not happen"); }
virtual void getDeviceNLine(Guchar * /*in*/, Guchar * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getDeviceNLine this should not happen"); }
// create mapping for spot colorants
virtual void createMapping(GooList *separationList, int maxSepComps);
// Does this ColorSpace support getRGBLine?
virtual GBool useGetRGBLine() { return gFalse; }
// Does this ColorSpace support getGrayLine?
virtual GBool useGetGrayLine() { return gFalse; }
// Does this ColorSpace support getCMYKLine?
virtual GBool useGetCMYKLine() { return gFalse; }
// Does this ColorSpace support getDeviceNLine?
virtual GBool useGetDeviceNLine() { return gFalse; }
// Return the number of color components.
virtual int getNComps() = 0;
// Get this color space's default color.
virtual void getDefaultColor(GfxColor *color) = 0;
// Return the default ranges for each component, assuming an image
// with a max pixel value of <maxImgPixel>.
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
// Returns true if painting operations in this color space never
// mark the page (e.g., the "None" colorant).
virtual GBool isNonMarking() { return gFalse; }
// Return the color space's overprint mask.
Guint getOverprintMask() { return overprintMask; }
// Return the number of color space modes
static int getNumColorSpaceModes();
// Return the name of the <idx>th color space mode.
static const char *getColorSpaceModeName(int idx);
#ifdef USE_CMS
static int setupColorProfiles();
// displayProfileA should be a cmsHPROFILE
static void setDisplayProfile(void *displayProfileA);
static void setDisplayProfileName(GooString *name);
// result will be a cmsHPROFILE
static void *getRGBProfile();
// result will be a cmsHPROFILE
static void *getDisplayProfile();
#endif
protected:
Guint overprintMask;
int *mapping;
};
//------------------------------------------------------------------------
// GfxDeviceGrayColorSpace
//------------------------------------------------------------------------
class GfxDeviceGrayColorSpace: public GfxColorSpace {
public:
GfxDeviceGrayColorSpace();
virtual ~GfxDeviceGrayColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual void getRGBLine(Guchar *in, Guchar *out, int length);
virtual void getRGBXLine(Guchar *in, Guchar *out, int length);
virtual void getCMYKLine(Guchar *in, Guchar *out, int length);
virtual void getDeviceNLine(Guchar *in, Guchar *out, int length);
virtual GBool useGetRGBLine() { return gTrue; }
virtual GBool useGetGrayLine() { return gTrue; }
virtual GBool useGetCMYKLine() { return gTrue; }
virtual GBool useGetDeviceNLine() { return gTrue; }
virtual int getNComps() { return 1; }
virtual void getDefaultColor(GfxColor *color);
private:
};
//------------------------------------------------------------------------
// GfxCalGrayColorSpace
//------------------------------------------------------------------------
class GfxCalGrayColorSpace: public GfxColorSpace {
public:
GfxCalGrayColorSpace();
virtual ~GfxCalGrayColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csCalGray; }
// Construct a CalGray color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual int getNComps() { return 1; }
virtual void getDefaultColor(GfxColor *color);
// CalGray-specific access.
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getGamma() { return gamma; }
private:
double whiteX, whiteY, whiteZ; // white point
double blackX, blackY, blackZ; // black point
double gamma; // gamma value
double kr, kg, kb; // gamut mapping mulitpliers
void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
#ifdef USE_CMS
GfxColorTransform *transform;
#endif
};
//------------------------------------------------------------------------
// GfxDeviceRGBColorSpace
//------------------------------------------------------------------------
class GfxDeviceRGBColorSpace: public GfxColorSpace {
public:
GfxDeviceRGBColorSpace();
virtual ~GfxDeviceRGBColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual void getRGBLine(Guchar *in, Guchar *out, int length);
virtual void getRGBXLine(Guchar *in, Guchar *out, int length);
virtual void getCMYKLine(Guchar *in, Guchar *out, int length);
virtual void getDeviceNLine(Guchar *in, Guchar *out, int length);
virtual GBool useGetRGBLine() { return gTrue; }
virtual GBool useGetGrayLine() { return gTrue; }
virtual GBool useGetCMYKLine() { return gTrue; }
virtual GBool useGetDeviceNLine() { return gTrue; }
virtual int getNComps() { return 3; }
virtual void getDefaultColor(GfxColor *color);
private:
};
//------------------------------------------------------------------------
// GfxCalRGBColorSpace
//------------------------------------------------------------------------
class GfxCalRGBColorSpace: public GfxColorSpace {
public:
GfxCalRGBColorSpace();
virtual ~GfxCalRGBColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csCalRGB; }
// Construct a CalRGB color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual int getNComps() { return 3; }
virtual void getDefaultColor(GfxColor *color);
// CalRGB-specific access.
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getGammaR() { return gammaR; }
double getGammaG() { return gammaG; }
double getGammaB() { return gammaB; }
double *getMatrix() { return mat; }
private:
double whiteX, whiteY, whiteZ; // white point
double blackX, blackY, blackZ; // black point
double gammaR, gammaG, gammaB; // gamma values
double mat[9]; // ABC -> XYZ transform matrix
double kr, kg, kb; // gamut mapping mulitpliers
void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
#ifdef USE_CMS
GfxColorTransform *transform;
#endif
};
//------------------------------------------------------------------------
// GfxDeviceCMYKColorSpace
//------------------------------------------------------------------------
class GfxDeviceCMYKColorSpace: public GfxColorSpace {
public:
GfxDeviceCMYKColorSpace();
virtual ~GfxDeviceCMYKColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual void getRGBLine(Guchar *, Guchar *out, int length);
virtual void getRGBXLine(Guchar *in, Guchar *out, int length);
virtual void getCMYKLine(Guchar *in, Guchar *out, int length);
virtual void getDeviceNLine(Guchar *in, Guchar *out, int length);
virtual GBool useGetRGBLine() { return gTrue; }
virtual GBool useGetCMYKLine() { return gTrue; }
virtual GBool useGetDeviceNLine() { return gTrue; }
virtual int getNComps() { return 4; }
virtual void getDefaultColor(GfxColor *color);
private:
};
//------------------------------------------------------------------------
// GfxLabColorSpace
//------------------------------------------------------------------------
class GfxLabColorSpace: public GfxColorSpace {
public:
GfxLabColorSpace();
virtual ~GfxLabColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csLab; }
// Construct a Lab color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual int getNComps() { return 3; }
virtual void getDefaultColor(GfxColor *color);
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
// Lab-specific access.
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getAMin() { return aMin; }
double getAMax() { return aMax; }
double getBMin() { return bMin; }
double getBMax() { return bMax; }
private:
double whiteX, whiteY, whiteZ; // white point
double blackX, blackY, blackZ; // black point
double aMin, aMax, bMin, bMax; // range for the a and b components
double kr, kg, kb; // gamut mapping mulitpliers
void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
#ifdef USE_CMS
GfxColorTransform *transform;
#endif
};
//------------------------------------------------------------------------
// GfxICCBasedColorSpace
//------------------------------------------------------------------------
class GfxICCBasedColorSpace: public GfxColorSpace {
public:
GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
Ref *iccProfileStreamA);
virtual ~GfxICCBasedColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csICCBased; }
// Construct an ICCBased color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual void getRGBLine(Guchar *in, Guchar *out, int length);
virtual void getRGBXLine(Guchar *in, Guchar *out, int length);
virtual void getCMYKLine(Guchar *in, Guchar *out, int length);
virtual void getDeviceNLine(Guchar *in, Guchar *out, int length);
virtual GBool useGetRGBLine();
virtual GBool useGetCMYKLine();
virtual GBool useGetDeviceNLine();
virtual int getNComps() { return nComps; }
virtual void getDefaultColor(GfxColor *color);
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
// ICCBased-specific access.
GfxColorSpace *getAlt() { return alt; }
private:
int nComps; // number of color components (1, 3, or 4)
GfxColorSpace *alt; // alternate color space
double rangeMin[4]; // min values for each component
double rangeMax[4]; // max values for each component
Ref iccProfileStream; // the ICC profile
#ifdef USE_CMS
int getIntent() { return (transform != NULL) ? transform->getIntent() : 0; }
GfxColorTransform *transform;
GfxColorTransform *lineTransform; // color transform for line
std::map<unsigned int, unsigned int> cmsCache;
#endif
};
//------------------------------------------------------------------------
// GfxIndexedColorSpace
//------------------------------------------------------------------------
class GfxIndexedColorSpace: public GfxColorSpace {
public:
GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
virtual ~GfxIndexedColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csIndexed; }
// Construct an Indexed color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual void getRGBLine(Guchar *in, Guchar *out, int length);
virtual void getRGBXLine(Guchar *in, Guchar *out, int length);
virtual void getCMYKLine(Guchar *in, Guchar *out, int length);
virtual void getDeviceNLine(Guchar *in, Guchar *out, int length);
virtual GBool useGetRGBLine() { return gTrue; }
virtual GBool useGetCMYKLine() { return gTrue; }
virtual GBool useGetDeviceNLine() { return gTrue; }
virtual int getNComps() { return 1; }
virtual void getDefaultColor(GfxColor *color);
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
// Indexed-specific access.
GfxColorSpace *getBase() { return base; }
int getIndexHigh() { return indexHigh; }
Guchar *getLookup() { return lookup; }
GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor);
Guint getOverprintMask() { return base->getOverprintMask(); }
virtual void createMapping(GooList *separationList, int maxSepComps)
{ base->createMapping(separationList, maxSepComps); }
private:
GfxColorSpace *base; // base color space
int indexHigh; // max pixel value
Guchar *lookup; // lookup table
};
//------------------------------------------------------------------------
// GfxSeparationColorSpace
//------------------------------------------------------------------------
class GfxSeparationColorSpace: public GfxColorSpace {
public:
GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA,
Function *funcA);
virtual ~GfxSeparationColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csSeparation; }
// Construct a Separation color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void createMapping(GooList *separationList, int maxSepComps);
virtual int getNComps() { return 1; }
virtual void getDefaultColor(GfxColor *color);
virtual GBool isNonMarking() { return nonMarking; }
// Separation-specific access.
GooString *getName() { return name; }
GfxColorSpace *getAlt() { return alt; }
Function *getFunc() { return func; }
private:
GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA,
Function *funcA, GBool nonMarkingA,
Guint overprintMaskA, int *mappingA);
GooString *name; // colorant name
GfxColorSpace *alt; // alternate color space
Function *func; // tint transform (into alternate color space)
GBool nonMarking;
};
//------------------------------------------------------------------------
// GfxDeviceNColorSpace
//------------------------------------------------------------------------
class GfxDeviceNColorSpace: public GfxColorSpace {
public:
GfxDeviceNColorSpace(int nCompsA, GooString **namesA,
GfxColorSpace *alt, Function *func, GooList *sepsCS);
virtual ~GfxDeviceNColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceN; }
// Construct a DeviceN color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual void createMapping(GooList *separationList, int maxSepComps);
virtual int getNComps() { return nComps; }
virtual void getDefaultColor(GfxColor *color);
virtual GBool isNonMarking() { return nonMarking; }
// DeviceN-specific access.
GooString *getColorantName(int i) { return names[i]; }
GfxColorSpace *getAlt() { return alt; }
Function *getTintTransformFunc() { return func; }
private:
GfxDeviceNColorSpace(int nCompsA, GooString **namesA,
GfxColorSpace *alt, Function *func, GooList *sepsCSA,
int *mappingA, GBool nonMarkingA, Guint overprintMaskA);
int nComps; // number of components
GooString // colorant names
*names[gfxColorMaxComps];
GfxColorSpace *alt; // alternate color space
Function *func; // tint transform (into alternate color space)
GBool nonMarking;
GooList *sepsCS; // list of separation cs for spot colorants;
};
//------------------------------------------------------------------------
// GfxPatternColorSpace
//------------------------------------------------------------------------
class GfxPatternColorSpace: public GfxColorSpace {
public:
GfxPatternColorSpace(GfxColorSpace *underA);
virtual ~GfxPatternColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csPattern; }
// Construct a Pattern color space. Returns NULL if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual void getDeviceN(GfxColor *color, GfxColor *deviceN);
virtual int getNComps() { return 0; }
virtual void getDefaultColor(GfxColor *color);
// Pattern-specific access.
GfxColorSpace *getUnder() { return under; }
private:
GfxColorSpace *under; // underlying color space (for uncolored
// patterns)
};
//------------------------------------------------------------------------
// GfxPattern
//------------------------------------------------------------------------
class GfxPattern {
public:
GfxPattern(int typeA, int patternRefNumA);
virtual ~GfxPattern();
static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum);
virtual GfxPattern *copy() = 0;
int getType() { return type; }
int getPatternRefNum() const { return patternRefNum; }
private:
int type;
int patternRefNum;
};
//------------------------------------------------------------------------
// GfxTilingPattern
//------------------------------------------------------------------------
class GfxTilingPattern: public GfxPattern {
public:
static GfxTilingPattern *parse(Object *patObj, int patternRefNum);
virtual ~GfxTilingPattern();
virtual GfxPattern *copy();
int getPaintType() { return paintType; }
int getTilingType() { return tilingType; }
double *getBBox() { return bbox; }
double getXStep() { return xStep; }
double getYStep() { return yStep; }
Dict *getResDict()
{ return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
double *getMatrix() { return matrix; }
Object *getContentStream() { return &contentStream; }
private:
GfxTilingPattern(int paintTypeA, int tilingTypeA,
double *bboxA, double xStepA, double yStepA,
Object *resDictA, double *matrixA,
Object *contentStreamA, int patternRefNumA);
int paintType;
int tilingType;
double bbox[4];
double xStep, yStep;
Object resDict;
double matrix[6];
Object contentStream;
};
//------------------------------------------------------------------------
// GfxShadingPattern
//------------------------------------------------------------------------
class GfxShadingPattern: public GfxPattern {
public:
static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum);
virtual ~GfxShadingPattern();
virtual GfxPattern *copy();
GfxShading *getShading() { return shading; }
double *getMatrix() { return matrix; }
private:
GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA);
GfxShading *shading;
double matrix[6];
};
//------------------------------------------------------------------------
// GfxShading
//------------------------------------------------------------------------
class GfxShading {
public:
GfxShading(int typeA);
GfxShading(GfxShading *shading);
virtual ~GfxShading();
static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
virtual GfxShading *copy() = 0;
int getType() { return type; }
GfxColorSpace *getColorSpace() { return colorSpace; }
GfxColor *getBackground() { return &background; }
GBool getHasBackground() { return hasBackground; }
void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
{ *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
GBool getHasBBox() { return hasBBox; }
protected:
GBool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
int type;
GBool hasBackground;
GBool hasBBox;
GfxColorSpace *colorSpace;
GfxColor background;
double xMin, yMin, xMax, yMax;
};
//------------------------------------------------------------------------
// GfxUnivariateShading
//------------------------------------------------------------------------
class GfxUnivariateShading: public GfxShading {
public:
GfxUnivariateShading(int typeA,
double t0A, double t1A,
Function **funcsA, int nFuncsA,
GBool extend0A, GBool extend1A);
GfxUnivariateShading(GfxUnivariateShading *shading);
virtual ~GfxUnivariateShading();
double getDomain0() { return t0; }
double getDomain1() { return t1; }
GBool getExtend0() { return extend0; }
GBool getExtend1() { return extend1; }
int getNFuncs() { return nFuncs; }
Function *getFunc(int i) { return funcs[i]; }
void getColor(double t, GfxColor *color);
void setupCache(const Matrix *ctm,
double xMin, double yMin,
double xMax, double yMax);
virtual void getParameterRange(double *lower, double *upper,
double xMin, double yMin,
double xMax, double yMax) = 0;
virtual double getDistance(double tMin, double tMax) = 0;
private:
double t0, t1;
Function *funcs[gfxColorMaxComps];
int nFuncs;
GBool extend0, extend1;
int cacheSize, lastMatch;
double *cacheBounds;
double *cacheCoeff;
double *cacheValues;
};
//------------------------------------------------------------------------
// GfxFunctionShading
//------------------------------------------------------------------------
class GfxFunctionShading: public GfxShading {
public:
GfxFunctionShading(double x0A, double y0A,
double x1A, double y1A,
double *matrixA,
Function **funcsA, int nFuncsA);
GfxFunctionShading(GfxFunctionShading *shading);
virtual ~GfxFunctionShading();
static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
virtual GfxShading *copy();
void getDomain(double *x0A, double *y0A, double *x1A, double *y1A)
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
double *getMatrix() { return matrix; }
int getNFuncs() { return nFuncs; }
Function *getFunc(int i) { return funcs[i]; }
void getColor(double x, double y, GfxColor *color);
private:
double x0, y0, x1, y1;
double matrix[6];
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
//------------------------------------------------------------------------
// GfxAxialShading
//------------------------------------------------------------------------
class GfxAxialShading: public GfxUnivariateShading {
public:
GfxAxialShading(double x0A, double y0A,
double x1A, double y1A,
double t0A, double t1A,
Function **funcsA, int nFuncsA,
GBool extend0A, GBool extend1A);
GfxAxialShading(GfxAxialShading *shading);
virtual ~GfxAxialShading();
static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
virtual GfxShading *copy();
void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
virtual void getParameterRange(double *lower, double *upper,
double xMin, double yMin,
double xMax, double yMax);
virtual double getDistance(double tMin, double tMax);
private:
double x0, y0, x1, y1;
};
//------------------------------------------------------------------------
// GfxRadialShading
//------------------------------------------------------------------------
class GfxRadialShading: public GfxUnivariateShading {
public:
GfxRadialShading(double x0A, double y0A, double r0A,
double x1A, double y1A, double r1A,
double t0A, double t1A,
Function **funcsA, int nFuncsA,
GBool extend0A, GBool extend1A);
GfxRadialShading(GfxRadialShading *shading);
virtual ~GfxRadialShading();
static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
virtual GfxShading *copy();
void getCoords(double *x0A, double *y0A, double *r0A,
double *x1A, double *y1A, double *r1A)
{ *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
virtual void getParameterRange(double *lower, double *upper,
double xMin, double yMin,
double xMax, double yMax);
virtual double getDistance(double tMin, double tMax);
private:
double x0, y0, r0, x1, y1, r1;
};
//------------------------------------------------------------------------
// GfxGouraudTriangleShading
//------------------------------------------------------------------------
struct GfxGouraudVertex {
double x, y;
GfxColor color;
};
class GfxGouraudTriangleShading: public GfxShading {
public:
GfxGouraudTriangleShading(int typeA,
GfxGouraudVertex *verticesA, int nVerticesA,
int (*trianglesA)[3], int nTrianglesA,
Function **funcsA, int nFuncsA);
GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
virtual ~GfxGouraudTriangleShading();
static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
virtual GfxShading *copy();
int getNTriangles() { return nTriangles; }
bool isParameterized() const { return nFuncs > 0; }
/**
* @precondition isParameterized() == true
*/
double getParameterDomainMin() const { assert(isParameterized()); return funcs[0]->getDomainMin(0); }
/**
* @precondition isParameterized() == true
*/
double getParameterDomainMax() const { assert(isParameterized()); return funcs[0]->getDomainMax(0); }
/**
* @precondition isParameterized() == false
*/
void getTriangle(int i, double *x0, double *y0, GfxColor *color0,
double *x1, double *y1, GfxColor *color1,
double *x2, double *y2, GfxColor *color2);
/**
* Variant for functions.
*
* @precondition isParameterized() == true
*/
void getTriangle(int i, double *x0, double *y0, double *color0,
double *x1, double *y1, double *color1,
double *x2, double *y2, double *color2);
void getParameterizedColor(double t, GfxColor *color);
private:
GfxGouraudVertex *vertices;
int nVertices;
int (*triangles)[3];
int nTriangles;
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
//------------------------------------------------------------------------
// GfxPatchMeshShading
//------------------------------------------------------------------------
/**
* A tensor product cubic bezier patch consisting of 4x4 points and 4 color
* values.
*
* See the Shading Type 7 specifications. Note that Shading Type 6 is also
* represented using GfxPatch.
*/
struct GfxPatch {
/**
* Represents a single color value for the patch.
*/
struct ColorValue {
/**
* For parameterized patches, only element 0 is valid; it contains
* the single parameter.
*
* For non-parameterized patches, c contains all color components
* as decoded from the input stream. In this case, you will need to
* use dblToCol() before assigning them to GfxColor.
*/
double c[gfxColorMaxComps];
};
double x[4][4];
double y[4][4];
ColorValue color[2][2];
};
class GfxPatchMeshShading: public GfxShading {
public:
GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA,
Function **funcsA, int nFuncsA);
GfxPatchMeshShading(GfxPatchMeshShading *shading);
virtual ~GfxPatchMeshShading();
static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
virtual GfxShading *copy();
int getNPatches() { return nPatches; }
GfxPatch *getPatch(int i) { return &patches[i]; }
bool isParameterized() const { return nFuncs > 0; }
/**
* @precondition isParameterized() == true
*/
double getParameterDomainMin() const { assert(isParameterized()); return funcs[0]->getDomainMin(0); }
/**
* @precondition isParameterized() == true
*/
double getParameterDomainMax() const { assert(isParameterized()); return funcs[0]->getDomainMax(0); }
void getParameterizedColor(double t, GfxColor *color);
private:
GfxPatch *patches;
int nPatches;
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
//------------------------------------------------------------------------
// GfxImageColorMap
//------------------------------------------------------------------------
class GfxImageColorMap {
public:
// Constructor.
GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
// Destructor.
~GfxImageColorMap();
// Return a copy of this color map.
GfxImageColorMap *copy() { return new GfxImageColorMap(this); }
// Is color map valid?
GBool isOk() { return ok; }
// Get the color space.
GfxColorSpace *getColorSpace() { return colorSpace; }
// Get stream decoding info.
int getNumPixelComps() { return nComps; }
int getBits() { return bits; }
// Get decode table.
double getDecodeLow(int i) { return decodeLow[i]; }
double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
bool useRGBLine() { return (colorSpace2 && colorSpace2->useGetRGBLine ()) || (!colorSpace2 && colorSpace->useGetRGBLine ()); }
bool useCMYKLine() { return (colorSpace2 && colorSpace2->useGetCMYKLine ()) || (!colorSpace2 && colorSpace->useGetCMYKLine ()); }
bool useDeviceNLine() { return (colorSpace2 && colorSpace2->useGetDeviceNLine ()) || (!colorSpace2 && colorSpace->useGetDeviceNLine ()); }
// Convert an image pixel to a color.
void getGray(Guchar *x, GfxGray *gray);
void getRGB(Guchar *x, GfxRGB *rgb);
void getRGBLine(Guchar *in, unsigned int *out, int length);
void getRGBLine(Guchar *in, Guchar *out, int length);
void getRGBXLine(Guchar *in, Guchar *out, int length);
void getGrayLine(Guchar *in, Guchar *out, int length);
void getCMYKLine(Guchar *in, Guchar *out, int length);
void getDeviceNLine(Guchar *in, Guchar *out, int length);
void getCMYK(Guchar *x, GfxCMYK *cmyk);
void getDeviceN(Guchar *x, GfxColor *deviceN);
void getColor(Guchar *x, GfxColor *color);
// Matte color ops
void setMatteColor(GfxColor *color) { useMatte = gTrue; matteColor = *color; }
GfxColor *getMatteColor() { return (useMatte) ? &matteColor : NULL; }
private:
GfxImageColorMap(GfxImageColorMap *colorMap);
GfxColorSpace *colorSpace; // the image color space
int bits; // bits per component
int nComps; // number of components in a pixel
GfxColorSpace *colorSpace2; // secondary color space
int nComps2; // number of components in colorSpace2
GfxColorComp * // lookup table
lookup[gfxColorMaxComps];
GfxColorComp * // optimized case lookup table
lookup2[gfxColorMaxComps];
Guchar *byte_lookup;
double // minimum values for each component
decodeLow[gfxColorMaxComps];
double // max - min value for each component
decodeRange[gfxColorMaxComps];
GBool useMatte;
GfxColor matteColor;
GBool ok;
};
//------------------------------------------------------------------------
// GfxSubpath and GfxPath
//------------------------------------------------------------------------
class GfxSubpath {
public:
// Constructor.
GfxSubpath(double x1, double y1);
// Destructor.
~GfxSubpath();
// Copy.
GfxSubpath *copy() { return new GfxSubpath(this); }
// Get points.
int getNumPoints() { return n; }
double getX(int i) { return x[i]; }
double getY(int i) { return y[i]; }
GBool getCurve(int i) { return curve[i]; }
void setX(int i, double a) { x[i] = a; }
void setY(int i, double a) { y[i] = a; }
// Get last point.
double getLastX() { return x[n-1]; }
double getLastY() { return y[n-1]; }
// Add a line segment.
void lineTo(double x1, double y1);
// Add a Bezier curve.
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3);
// Close the subpath.
void close();
GBool isClosed() { return closed; }
// Add (<dx>, <dy>) to each point in the subpath.
void offset(double dx, double dy);
private:
double *x, *y; // points
GBool *curve; // curve[i] => point i is a control point
// for a Bezier curve
int n; // number of points
int size; // size of x/y arrays
GBool closed; // set if path is closed
GfxSubpath(GfxSubpath *subpath);
};
class GfxPath {
public:
// Constructor.
GfxPath();
// Destructor.
~GfxPath();
// Copy.
GfxPath *copy()
{ return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
// Is there a current point?
GBool isCurPt() { return n > 0 || justMoved; }
// Is the path non-empty, i.e., is there at least one segment?
GBool isPath() { return n > 0; }
// Get subpaths.
int getNumSubpaths() { return n; }
GfxSubpath *getSubpath(int i) { return subpaths[i]; }
// Get last point on last subpath.
double getLastX() { return subpaths[n-1]->getLastX(); }
double getLastY() { return subpaths[n-1]->getLastY(); }
// Move the current point.
void moveTo(double x, double y);
// Add a segment to the last subpath.
void lineTo(double x, double y);
// Add a Bezier curve to the last subpath
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3);
// Close the last subpath.
void close();
// Append <path> to <this>.
void append(GfxPath *path);
// Add (<dx>, <dy>) to each point in the path.
void offset(double dx, double dy);
private:
GBool justMoved; // set if a new subpath was just started
double firstX, firstY; // first point in new subpath
GfxSubpath **subpaths; // subpaths
int n; // number of subpaths
int size; // size of subpaths array
GfxPath(GBool justMoved1, double firstX1, double firstY1,
GfxSubpath **subpaths1, int n1, int size1);
};
//------------------------------------------------------------------------
// GfxState
//------------------------------------------------------------------------
class GfxState {
public:
/**
* When GfxState::getReusablePath() is invoked, the currently active
* path is taken per reference and its coordinates can be re-edited.
*
* A ReusablePathIterator is intented to reduce overhead when the same
* path type is used a lot of times, only with different coordinates. It
* allows just to update the coordinates (occuring in the same order as
* in the original path).
*/
class ReusablePathIterator {
public:
/**
* Creates the ReusablePathIterator. This should only be done from
* GfxState::getReusablePath().
*
* @param path the path as it is used so far. Changing this path,
* deleting it or starting a new path from scratch will most likely
* invalidate the iterator (and may cause serious problems). Make
* sure the path's memory structure is not changed during the
* lifetime of the ReusablePathIterator.
*/
ReusablePathIterator( GfxPath* path );
/**
* Returns true if and only if the current iterator position is
* beyond the last valid point.
*
* A call to setCoord() will be undefined.
*/
bool isEnd() const;
/**
* Advances the iterator.
*/
void next();
/**
* Updates the coordinates associated to the current iterator
* position.
*/
void setCoord( double x, double y );
/**
* Resets the iterator.
*/
void reset();
private:
GfxPath *path;
int subPathOff;
int coordOff;
int numCoords;
GfxSubpath *curSubPath;
};
// Construct a default GfxState, for a device with resolution <hDPI>
// x <vDPI>, page box <pageBox>, page rotation <rotateA>, and
// coordinate system specified by <upsideDown>.
GfxState(double hDPIA, double vDPIA, PDFRectangle *pageBox,
int rotateA, GBool upsideDown);
// Destructor.
~GfxState();
// Copy.
GfxState *copy(GBool copyPath = gFalse)
{ return new GfxState(this, copyPath); }
// Accessors.
double getHDPI() { return hDPI; }
double getVDPI() { return vDPI; }
double *getCTM() { return ctm; }
void getCTM(Matrix *m) { memcpy (m->m, ctm, sizeof m->m); }
double getX1() { return px1; }
double getY1() { return py1; }
double getX2() { return px2; }
double getY2() { return py2; }
double getPageWidth() { return pageWidth; }
double getPageHeight() { return pageHeight; }
int getRotate() { return rotate; }
GfxColor *getFillColor() { return &fillColor; }
GfxColor *getStrokeColor() { return &strokeColor; }
void getFillGray(GfxGray *gray)
{ fillColorSpace->getGray(&fillColor, gray); }
void getStrokeGray(GfxGray *gray)
{ strokeColorSpace->getGray(&strokeColor, gray); }
void getFillRGB(GfxRGB *rgb)
{ fillColorSpace->getRGB(&fillColor, rgb); }
void getStrokeRGB(GfxRGB *rgb)
{ strokeColorSpace->getRGB(&strokeColor, rgb); }
void getFillCMYK(GfxCMYK *cmyk)
{ fillColorSpace->getCMYK(&fillColor, cmyk); }
void getFillDeviceN(GfxColor *deviceN)
{ fillColorSpace->getDeviceN(&fillColor, deviceN); }
void getStrokeCMYK(GfxCMYK *cmyk)
{ strokeColorSpace->getCMYK(&strokeColor, cmyk); }
void getStrokeDeviceN(GfxColor *deviceN)
{ strokeColorSpace->getDeviceN(&strokeColor, deviceN); }
GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
GfxPattern *getFillPattern() { return fillPattern; }
GfxPattern *getStrokePattern() { return strokePattern; }
GfxBlendMode getBlendMode() { return blendMode; }
double getFillOpacity() { return fillOpacity; }
double getStrokeOpacity() { return strokeOpacity; }
GBool getFillOverprint() { return fillOverprint; }
GBool getStrokeOverprint() { return strokeOverprint; }
int getOverprintMode() { return overprintMode; }
Function **getTransfer() { return transfer; }
double getLineWidth() { return lineWidth; }
void getLineDash(double **dash, int *length, double *start)
{ *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
int getFlatness() { return flatness; }
int getLineJoin() { return lineJoin; }
int getLineCap() { return lineCap; }
double getMiterLimit() { return miterLimit; }
GBool getStrokeAdjust() { return strokeAdjust; }
GBool getAlphaIsShape() { return alphaIsShape; }
GBool getTextKnockout() { return textKnockout; }
GfxFont *getFont() { return font; }
double getFontSize() { return fontSize; }
double *getTextMat() { return textMat; }
double getCharSpace() { return charSpace; }
double getWordSpace() { return wordSpace; }
double getHorizScaling() { return horizScaling; }
double getLeading() { return leading; }
double getRise() { return rise; }
int getRender() { return render; }
char *getRenderingIntent() { return renderingIntent; }
GfxPath *getPath() { return path; }
void setPath(GfxPath *pathA);
double getCurX() { return curX; }
double getCurY() { return curY; }
void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax)
{ *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
double getLineX() { return lineX; }
double getLineY() { return lineY; }
// Is there a current point/path?
GBool isCurPt() { return path->isCurPt(); }
GBool isPath() { return path->isPath(); }
// Transforms.
void transform(double x1, double y1, double *x2, double *y2)
{ *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
*y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
void transformDelta(double x1, double y1, double *x2, double *y2)
{ *x2 = ctm[0] * x1 + ctm[2] * y1;
*y2 = ctm[1] * x1 + ctm[3] * y1; }
void textTransform(double x1, double y1, double *x2, double *y2)
{ *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
*y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
void textTransformDelta(double x1, double y1, double *x2, double *y2)
{ *x2 = textMat[0] * x1 + textMat[2] * y1;
*y2 = textMat[1] * x1 + textMat[3] * y1; }
double transformWidth(double w);
double getTransformedLineWidth()
{ return transformWidth(lineWidth); }
double getTransformedFontSize();
void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
// Change state parameters.
void setCTM(double a, double b, double c,
double d, double e, double f);
void concatCTM(double a, double b, double c,
double d, double e, double f);
void shiftCTMAndClip(double tx, double ty);
void setFillColorSpace(GfxColorSpace *colorSpace);
void setStrokeColorSpace(GfxColorSpace *colorSpace);
void setFillColor(GfxColor *color) { fillColor = *color; }
void setStrokeColor(GfxColor *color) { strokeColor = *color; }
void setFillPattern(GfxPattern *pattern);
void setStrokePattern(GfxPattern *pattern);
void setBlendMode(GfxBlendMode mode) { blendMode = mode; }
void setFillOpacity(double opac) { fillOpacity = opac; }
void setStrokeOpacity(double opac) { strokeOpacity = opac; }
void setFillOverprint(GBool op) { fillOverprint = op; }
void setStrokeOverprint(GBool op) { strokeOverprint = op; }
void setOverprintMode(int op) { overprintMode = op; }
void setTransfer(Function **funcs);
void setLineWidth(double width) { lineWidth = width; }
void setLineDash(double *dash, int length, double start);
void setFlatness(int flatness1) { flatness = flatness1; }
void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
void setLineCap(int lineCap1) { lineCap = lineCap1; }
void setMiterLimit(double limit) { miterLimit = limit; }
void setStrokeAdjust(GBool sa) { strokeAdjust = sa; }
void setAlphaIsShape(GBool ais) { alphaIsShape = ais; }
void setTextKnockout(GBool tk) { textKnockout = tk; }
void setFont(GfxFont *fontA, double fontSizeA);
void setTextMat(double a, double b, double c,
double d, double e, double f)
{ textMat[0] = a; textMat[1] = b; textMat[2] = c;
textMat[3] = d; textMat[4] = e; textMat[5] = f; }
void setCharSpace(double space)
{ charSpace = space; }
void setWordSpace(double space)
{ wordSpace = space; }
void setHorizScaling(double scale)
{ horizScaling = 0.01 * scale; }
void setLeading(double leadingA)
{ leading = leadingA; }
void setRise(double riseA)
{ rise = riseA; }
void setRender(int renderA)
{ render = renderA; }
void setRenderingIntent(const char *intent)
{ strncpy(renderingIntent, intent, 31); }
#ifdef USE_CMS
void setDisplayProfile(void *localDisplayProfileA);
void *getDisplayProfile() { return localDisplayProfile; }
GfxColorTransform *getXYZ2DisplayTransform();
#endif
// Add to path.
void moveTo(double x, double y)
{ path->moveTo(curX = x, curY = y); }
void lineTo(double x, double y)
{ path->lineTo(curX = x, curY = y); }
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3)
{ path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
void closePath()
{ path->close(); curX = path->getLastX(); curY = path->getLastY(); }
void clearPath();
// Update clip region.
void clip();
void clipToStrokePath();
void clipToRect(double xMin, double yMin, double xMax, double yMax);
// Text position.
void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; }
void textMoveTo(double tx, double ty)
{ lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
void textShift(double tx, double ty);
void shift(double dx, double dy);
// Push/pop GfxState on/off stack.
GfxState *save();
GfxState *restore();
GBool hasSaves() { return saved != NULL; }
GBool isParentState(GfxState *state) { return saved == state || (saved && saved->isParentState(state)); }
// Misc
GBool parseBlendMode(Object *obj, GfxBlendMode *mode);
ReusablePathIterator *getReusablePath() { return new ReusablePathIterator(path); }
private:
double hDPI, vDPI; // resolution
double ctm[6]; // coord transform matrix
double px1, py1, px2, py2; // page corners (user coords)
double pageWidth, pageHeight; // page size (pixels)
int rotate; // page rotation angle
GfxColorSpace *fillColorSpace; // fill color space
GfxColorSpace *strokeColorSpace; // stroke color space
GfxColor fillColor; // fill color
GfxColor strokeColor; // stroke color
GfxPattern *fillPattern; // fill pattern
GfxPattern *strokePattern; // stroke pattern
GfxBlendMode blendMode; // transparency blend mode
double fillOpacity; // fill opacity
double strokeOpacity; // stroke opacity
GBool fillOverprint; // fill overprint
GBool strokeOverprint; // stroke overprint
int overprintMode; // overprint mode
Function *transfer[4]; // transfer function (entries may be: all
// NULL = identity; last three NULL =
// single function; all four non-NULL =
// R,G,B,gray functions)
double lineWidth; // line width
double *lineDash; // line dash
int lineDashLength;
double lineDashStart;
int flatness; // curve flatness
int lineJoin; // line join style
int lineCap; // line cap style
double miterLimit; // line miter limit
GBool strokeAdjust; // stroke adjustment
GBool alphaIsShape; // alpha is shape
GBool textKnockout; // text knockout
GfxFont *font; // font
double fontSize; // font size
double textMat[6]; // text matrix
double charSpace; // character spacing
double wordSpace; // word spacing
double horizScaling; // horizontal scaling
double leading; // text leading
double rise; // text rise
int render; // text rendering mode
GfxPath *path; // array of path elements
double curX, curY; // current point (user coords)
double lineX, lineY; // start of current text line (text coords)
double clipXMin, clipYMin, // bounding box for clip region
clipXMax, clipYMax;
char renderingIntent[32];
GfxState *saved; // next GfxState on stack
GfxState(GfxState *state, GBool copyPath);
#ifdef USE_CMS
void *localDisplayProfile;
int displayProfileRef;
GfxColorTransform *XYZ2DisplayTransformRelCol;
GfxColorTransform *XYZ2DisplayTransformAbsCol;
GfxColorTransform *XYZ2DisplayTransformSat;
GfxColorTransform *XYZ2DisplayTransformPerc;
#endif
};
#endif
|