8#include "qplatformdefs.h"
10#include <private/qfont_p.h>
11#include <private/qmath_p.h>
12#include <private/qpainter_p.h>
64 if (
color.alpha() != 255) {
82 for (
int i = 0;
i < stops.
size(); ++
i) {
83 if (stops[
i].second.alpha() != 255)
84 stops[
i].second.setAlpha(255);
113 unsigned int ival = (
unsigned int)
val;
116 int ifrac = (int)(frac * 1000000000);
117 if (ifrac == 1000000000) {
128 int fact = 100000000;
142 *(
buf++) =
'0' + ((ifrac/fact) % 10);
179 fileBackingEnabled(fileBacking),
180 fileBackingActive(
false),
188 fileBackingEnabled(fileBacking),
189 fileBackingActive(
false),
202 if (handleDirty) prepareBuffer();
209 if (handleDirty) prepareBuffer();
216 if (handleDirty) prepareBuffer();
224 if (handleDirty) prepareBuffer();
230 while (!
s.dev->atEnd()) {
280 void ByteStream::prepareBuffer()
284 if (fileBackingEnabled && !fileBackingActive
290 while (!dev->
atEnd()) {
297 fileBackingActive =
true;
306#define QT_PATH_ELEMENT(elm)
311 if (!
path.elementCount())
317 for (
int i = 0;
i <
path.elementCount(); ++
i) {
341 qFatal(
"QPdf::generatePath(), unhandled type: %d", elm.
type);
394 for (
int i = 0;
i < dasharray.
size(); ++
i) {
396 if (dw < 0.0001) dw = 0.0001;
562 int style =
b.style();
575 t->matrix.map(
x,
y, &
x, &
y);
585 *
t->stream <<
x <<
y <<
"l\n";
594 if (!
t->cosmeticPen) {
596 t->matrix.map(c2x, c2y, &c2x, &c2y);
597 t->matrix.map(ex, ey, &ex, &ey);
599 *
t->stream << c1x << c1y
608 dashStroker(&basicStroker)
610 stroker = &basicStroker;
625 bool zeroWidth =
w < 0.0001;
630 basicStroker.setStrokeWidth(
w);
631 basicStroker.setCapStyle(pen.
capStyle());
632 basicStroker.setJoinStyle(pen.
joinStyle());
637 for (
int i = 0;
i < dashpattern.
size(); ++
i)
638 dashpattern[
i] *= 10.;
641 dashStroker.setDashPattern(dashpattern);
643 stroker = &dashStroker;
645 stroker = &basicStroker;
666 for (
int i = 0;
i < isize;
i += 4) {
693 for (
int i = isize;
i <
input.size(); ++
i)
695 val <<= 8*(4-remaining);
706 for (
int i = 0;
i < remaining+1; ++
i)
749 :
QPdf::ByteStream(true)
755 *
this <<
w <<
"0 0 " << -
h <<
"0 " <<
h <<
"cm /Im" <<
object <<
" Do\n";
774 d->outputFileName = filename;
785 for (
int i=0;
i!=pointCount;++
i) {
790 bool hadBrush =
d->hasBrush;
793 d->hasBrush = hadBrush;
803 for (
int i=0;
i!=lineCount;++
i) {
804 p.moveTo(lines[
i].
p1());
805 p.lineTo(lines[
i].
p2());
807 bool hadBrush =
d->hasBrush;
810 d->hasBrush = hadBrush;
820 if (
d->clipEnabled &&
d->allClipped)
822 if (!
d->hasPen && !
d->hasBrush)
825 if ((
d->simplePen && !
d->needsTransform) || !
d->hasPen) {
827 if (!
d->hasPen &&
d->needsTransform)
829 for (
int i = 0;
i < rectCount; ++
i)
830 *
d->currentPage << rects[
i].
x() << rects[
i].
y() << rects[
i].
width() << rects[
i].
height() <<
"re\n";
831 *
d->currentPage << (
d->hasPen ? (
d->hasBrush ?
"B\n" :
"S\n") :
"f\n");
832 if (!
d->hasPen &&
d->needsTransform)
833 *
d->currentPage <<
"Q\n";
836 for (
int i=0;
i!=rectCount; ++
i)
846 if (!
points || !pointCount)
849 bool hb =
d->hasBrush;
868 for (
int i = 1;
i < pointCount; ++
i)
882 if (
d->clipEnabled &&
d->allClipped)
884 if (!
d->hasPen && !
d->hasBrush)
895 *
d->currentPage <<
"q\n";
897 d->brush =
d->pen.brush();
899 d->stroker.strokePath(
p);
900 *
d->currentPage <<
"Q\n";
923 *
d->currentPage <<
"q\n";
926 int stateObject =
d->addConstantAlphaObject(
qRound(255 *
d->opacity),
qRound(255 *
d->opacity));
928 *
d->currentPage <<
"/GState" << stateObject <<
"gs\n";
930 *
d->currentPage <<
"/GSa gs\n";
932 *
d->currentPage <<
"/GSa gs\n";
937 rectangle.
x(), rectangle.
y()) * (!
d->needsTransform ?
QTransform() :
d->stroker.matrix));
940 d->brush =
d->pen.brush();
943 d->currentPage->streamImage(
image.width(),
image.height(),
object);
944 *
d->currentPage <<
"Q\n";
963 *
d->currentPage <<
"q\n";
966 int stateObject =
d->addConstantAlphaObject(
qRound(255 *
d->opacity),
qRound(255 *
d->opacity));
968 *
d->currentPage <<
"/GState" << stateObject <<
"gs\n";
970 *
d->currentPage <<
"/GSa gs\n";
972 *
d->currentPage <<
"/GSa gs\n";
977 rectangle.
x(), rectangle.
y()) * (!
d->needsTransform ?
QTransform() :
d->stroker.matrix));
979 d->currentPage->streamImage(im.
width(), im.
height(),
object);
980 *
d->currentPage <<
"Q\n";
992 bool hb =
d->hasBrush;
998 d->brush.setColor(
d->pen.color());
1000 d->brushOrigin = -point;
1001 *
d->currentPage <<
"q\n";
1005 *
d->currentPage <<
"Q\n";
1010 d->brushOrigin = bo;
1017 if (!
d->hasPen || (
d->clipEnabled &&
d->allClipped))
1025 *
d->currentPage <<
"q\n";
1026 if (
d->needsTransform)
1029 bool hp =
d->hasPen;
1032 d->brush =
d->pen.brush();
1037 d->drawTextItem(
p, ti);
1040 *
d->currentPage <<
"Q\n";
1047 const uint annot =
d->addXrefEntry(-1);
1052 for (
int j = 0;
j <
len;
j++) {
1053 if (urlascii[
j] ==
'(' || urlascii[
j] ==
')' || urlascii[
j] ==
'\\')
1060 const QRectF rr =
d->pageMatrix().mapRect(
r);
1061 d->xprintf(
"<<\n/Type /Annot\n/Subtype /Link\n");
1064 d->xprintf(
"/F 4\n");
1066 d->xprintf(
"/Rect [");
1071 d->xprintf(
"]\n/Border [0 0 0]\n/A <<\n");
1072 d->xprintf(
"/Type /Action\n/S /URI\n/URI (%s)\n", url_esc.
constData());
1073 d->xprintf(
">>\n>>\n");
1074 d->xprintf(
"endobj\n");
1075 d->currentPage->annotations.append(annot);
1095 if (penColor.
alpha() != 255)
1108 bool oldCosmetic =
d->stroker.cosmeticPen;
1110 QBrush penBrush =
d->pen.brush();
1111 bool oldSimple =
d->simplePen;
1113 if (oldSimple !=
d->simplePen || oldCosmetic !=
d->stroker.cosmeticPen)
1136 if (
d->simplePen &&
d->opacity != 1.0) {
1137 d->simplePen =
false;
1142 bool ce =
d->clipEnabled;
1144 d->clipEnabled =
true;
1147 d->clipEnabled =
true;
1157 if (ce !=
d->clipEnabled)
1159 else if (!
d->clipEnabled)
1160 flags &= ~DirtyClipPath;
1172 *
d->currentPage <<
"Q\n";
1177 *
d->currentPage <<
"Q q\n";
1179 d->allClipped =
false;
1180 if (
d->clipEnabled && !
d->clips.isEmpty()) {
1181 for (
int i = 0;
i <
d->clips.size(); ++
i) {
1182 if (
d->clips.at(
i).isEmpty()) {
1183 d->allClipped =
true;
1187 if (!
d->allClipped) {
1188 for (
int i = 0;
i <
d->clips.size(); ++
i) {
1196 *
d->currentPage <<
"q\n";
1197 d->needsTransform =
false;
1198 if (!
d->stroker.matrix.isIdentity()) {
1199 if (
d->simplePen && !
d->stroker.cosmeticPen)
1202 d->needsTransform =
true;
1221 d->clipEnabled =
false;
1226 d->clips.append(
path);
1229 d->clips.append(
path);
1245 *
d->currentPage << gray << gray << gray;
1247 *
d->currentPage << rgba.
redF()
1251 *
d->currentPage <<
"SCN\n";
1253 *
d->currentPage <<
d->pen.widthF() <<
"w ";
1255 int pdfCapStyle = 0;
1256 switch(
d->pen.capStyle()) {
1269 *
d->currentPage << pdfCapStyle <<
"J ";
1271 int pdfJoinStyle = 0;
1272 switch(
d->pen.joinStyle()) {
1275 *
d->currentPage <<
qMax(
qreal(1.0),
d->pen.miterLimit()) <<
"M ";
1287 *
d->currentPage << pdfJoinStyle <<
"j ";
1301 int gStateObject = 0;
1302 int patternObject =
d->addBrushPattern(
d->stroker.matrix, &specifyColor, &gStateObject);
1303 if (!patternObject && !specifyColor)
1306 *
d->currentPage << (patternObject ?
"/PCSp cs " :
"/CSp cs ");
1308 QColor rgba =
d->brush.color();
1311 *
d->currentPage << gray << gray << gray;
1313 *
d->currentPage << rgba.
redF()
1319 *
d->currentPage <<
"/Pat" << patternObject;
1320 *
d->currentPage <<
"scn\n";
1323 *
d->currentPage <<
"/GState" << gStateObject <<
"gs\n";
1325 *
d->currentPage <<
"/GSa gs\n";
1337 QFile *outfile = qobject_cast<QFile*> (
d->outDevice);
1357 return d->resolution;
1363 d->pdfVersion = version;
1369 d->xmpDocumentMetadata = xmpMetadata;
1375 return d->xmpDocumentMetadata;
1387 d->m_pageLayout.setPageSize(pageSize);
1393 d->m_pageLayout.setOrientation(orientation);
1399 d->m_pageLayout.setUnits(
units);
1400 d->m_pageLayout.setMargins(margins);
1406 return d->m_pageLayout;
1414 switch (metricType) {
1416 val =
d->m_pageLayout.paintRectPixels(
d->resolution).width();
1419 val =
d->m_pageLayout.paintRectPixels(
d->resolution).height();
1423 val =
d->resolution;
1448 qWarning(
"QPdfWriter::metric: Invalid metric command");
1478 if (!
d->outDevice) {
1479 if (!
d->outputFileName.isEmpty()) {
1485 d->outDevice =
file;
1489 d->ownsDevice =
true;
1492 d->currentObject = 1;
1495 d->stroker.stream =
d->currentPage;
1498 d->stream->setDevice(
d->outDevice);
1502 d->hasBrush =
false;
1503 d->clipEnabled =
false;
1504 d->allClipped =
false;
1506 d->xrefPositions.clear();
1510 d->attachmentsRoot = 0;
1513 d->graphicsState = 0;
1514 d->patternColorSpace = 0;
1515 d->simplePen =
false;
1516 d->needsTransform =
false;
1519 d->imageCache.clear();
1520 d->alphaCache.clear();
1534 d->stream->setDevice(
nullptr);
1538 delete d->currentPage;
1539 d->currentPage =
nullptr;
1541 if (
d->outDevice &&
d->ownsDevice) {
1542 d->outDevice->close();
1543 delete d->outDevice;
1544 d->outDevice =
nullptr;
1547 d->destCache.clear();
1548 d->fileCache.clear();
1569 addXrefEntry(0,
false);
1572 static const char mapping[][4] = {
1577 static const size_t numMappings =
sizeof mapping /
sizeof *
mapping;
1580 xprintf(
"%%PDF-%s\n", verStr);
1581 xprintf(
"%%\303\242\303\243\n");
1585 int metaDataObj = -1;
1586 int outputIntentObj = -1;
1588 metaDataObj = writeXmpDcumentMetaData();
1591 outputIntentObj = writeOutputIntent();
1594 catalog = addXrefEntry(-1);
1603 <<
"/Type /Catalog\n"
1604 <<
"/Pages " << pageRoot <<
"0 R\n"
1605 <<
"/Names " << namesRoot <<
"0 R\n";
1608 s <<
"/Metadata " << metaDataObj <<
"0 R\n";
1611 s <<
"/OutputIntents [" << outputIntentObj <<
"0 R]\n";
1620 graphicsState = addXrefEntry(-1);
1622 "/Type /ExtGState\n"
1633 patternColorSpace = addXrefEntry(-1);
1634 xprintf(
"[/Pattern /DeviceRGB]\n"
1638void QPdfEnginePrivate::writeInfo()
1640 info = addXrefEntry(-1);
1641 xprintf(
"<<\n/Title ");
1643 xprintf(
"\n/Creator ");
1645 xprintf(
"\n/Producer ");
1650 xprintf(
"\n/CreationDate (D:%d%02d%02d%02d%02d%02d",
1658 int hours = (
offset / 60) / 60;
1659 int mins = (
offset / 60) % 60;
1661 xprintf(
"-%02d'%02d')\n", -hours, -mins);
1663 xprintf(
"+%02d'%02d')\n", hours , mins);
1670int QPdfEnginePrivate::writeXmpDcumentMetaData()
1672 const int metaDataObj = addXrefEntry(-1);
1675 if (xmpDocumentMetadata.
isEmpty()) {
1687 const int hours = (
offset / 60) / 60;
1688 const int mins = (
offset / 60) % 60;
1697 const QString metaDataDate = timeStr + tzStr;
1699 QFile metaDataFile(
":/qpdf/qpdfa_metadata.xml"_L1);
1707 metaDataContent = xmpDocumentMetadata;
1710 "/Type /Metadata /Subtype /XML\n"
1713 "stream\n", metaDataContent.
size());
1714 write(metaDataContent);
1715 xprintf(
"\nendstream\n"
1721int QPdfEnginePrivate::writeOutputIntent()
1723 const int colorProfile = addXrefEntry(-1);
1725 QFile colorProfileFile(
":/qpdf/sRGB2014.icc"_L1);
1727 const QByteArray colorProfileData = colorProfileFile.readAll();
1735 s <<
"/Alternate /DeviceRGB\n";
1736 s <<
"/Length " << length_object <<
"0 R\n";
1737 s <<
"/Filter /FlateDecode\n";
1741 const int len = writeCompressed(colorProfileData);
1742 write(
"\nendstream\n"
1744 addXrefEntry(length_object);
1749 const int outputIntent = addXrefEntry(-1);
1752 xprintf(
"/Type /OutputIntent\n");
1753 xprintf(
"/S/GTS_PDFA1\n");
1754 xprintf(
"/OutputConditionIdentifier (sRGB_IEC61966-2-1_black_scaled)\n");
1755 xprintf(
"/DestOutputProfile %d 0 R\n", colorProfile);
1756 xprintf(
"/Info(sRGB IEC61966 v2.1 with black scaling)\n");
1757 xprintf(
"/RegistryName(http://www.color.org)\n");
1759 xprintf(
"endobj\n");
1762 return outputIntent;
1765void QPdfEnginePrivate::writePageRoot()
1767 addXrefEntry(pageRoot);
1774 for (
int i = 0;
i <
size; ++
i)
1775 xprintf(
"%d 0 R\n", pages[
i]);
1779 xprintf(
"/Count %d\n", pages.
size());
1781 xprintf(
"/ProcSet [/PDF /Text /ImageB /ImageC]\n"
1786void QPdfEnginePrivate::writeDestsRoot()
1793 for (
const DestInfo &destInfo :
std::as_const(destCache)) {
1794 int destObj = addXrefEntry(-1);
1795 xs.
setNum(
static_cast<double>(destInfo.coords.x()),
'f');
1796 ys.
setNum(
static_cast<double>(destInfo.coords.y()),
'f');
1797 xprintf(
"[%d 0 R /XYZ %s %s 0]\n", destInfo.pageObj, xs.
constData(), ys.
constData());
1798 xprintf(
"endobj\n");
1799 destObjects.
insert(destInfo.anchor, destObj);
1803 destsRoot = addXrefEntry(-1);
1806 xprintf(
"<<\n/Limits [");
1807 printString(
anchors.constFirst());
1809 printString(
anchors.constLast());
1810 xprintf(
"]\n/Names [\n");
1812 printString(anchor);
1813 xprintf(
" %d 0 R\n", destObjects[anchor]);
1819void QPdfEnginePrivate::writeAttachmentRoot()
1826 for (
int i = 0;
i <
size; ++
i) {
1828 const int attachmentID = addXrefEntry(-1);
1831 xprintf(
"/Filter /FlateDecode\n");
1834 xprintf(
"/Length %d 0 R\n", lenobj);
1836 xprintf(
">>\nstream\n");
1838 xprintf(
"\nendstream\n"
1840 addXrefEntry(lenobj);
1846 "/F (%s)",
attachment.fileName.toLatin1().constData());
1848 xprintf(
"\n/EF <</F %d 0 R>>\n"
1852 xprintf(
"/Subtype/%s\n",
1853 attachment.mimeType.replace(
"/"_L1,
"#2F"_L1).toLatin1().constData());
1854 xprintf(
">>\nendobj\n");
1858 attachmentsRoot = addXrefEntry(-1);
1859 xprintf(
"<</Names[");
1860 for (
int i = 0;
i <
size; ++
i) {
1869void QPdfEnginePrivate::writeNamesRoot()
1871 addXrefEntry(namesRoot);
1874 if (attachmentsRoot)
1875 xprintf(
"/EmbeddedFiles %d 0 R\n", attachmentsRoot);
1878 xprintf(
"/Dests %d 0 R\n", destsRoot);
1881 xprintf(
"endobj\n");
1887 int fontObject =
font->object_id;
1910 addXrefEntry(fontDescriptor);
1913 s <<
"<< /Type /FontDescriptor\n"
1915 int tag = fontDescriptor;
1916 for (
int i = 0;
i < 5; ++
i) {
1917 s << (char)(
'A' + (
tag % 26));
1920 s <<
'+' << postscriptName <<
"\n"
1921 "/Flags " << 4 <<
"\n"
1927 "/ItalicAngle " <<
properties.italicAngle.toReal() <<
"\n"
1932 "/FontFile2 " << fontstream <<
"0 R\n"
1933 "/CIDSet " << cidset <<
"0 R\n"
1938 addXrefEntry(fontstream);
1944 "/Length1 " <<
fontData.size() <<
"\n"
1945 "/Length " << length_object <<
"0 R\n";
1947 s <<
"/Filter /FlateDecode\n";
1952 write(
"\nendstream\n"
1954 addXrefEntry(length_object);
1959 addXrefEntry(cidfont);
1962 s <<
"<< /Type /Font\n"
1963 "/Subtype /CIDFontType2\n"
1964 "/BaseFont /" << postscriptName <<
"\n"
1965 "/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>\n"
1966 "/FontDescriptor " << fontDescriptor <<
"0 R\n"
1967 "/CIDToGIDMap /Identity\n"
1968 <<
font->widthArray() <<
1974 addXrefEntry(toUnicode);
1976 xprintf(
"<< /Length %d >>\n"
1977 "stream\n", touc.
size());
1979 write(
"\nendstream\n"
1983 addXrefEntry(fontObject);
1986 s <<
"<< /Type /Font\n"
1988 "/BaseFont /" << postscriptName <<
"\n"
1989 "/Encoding /Identity-H\n"
1990 "/DescendantFonts [" << cidfont <<
"0 R]\n"
1991 "/ToUnicode " << toUnicode <<
"0 R"
1998 int byteCounter = 0;
2001 cidSetStream.data()[byteCounter] |= (1 << (7 - bitCounter));
2004 if (bitCounter == 8) {
2010 addXrefEntry(cidset);
2012 xprintf(
"/Length %d\n", cidSetStream.size());
2014 xprintf(
"stream\n");
2015 write(cidSetStream);
2016 xprintf(
"\nendstream\n");
2017 xprintf(
"endobj\n");
2021qreal QPdfEnginePrivate::calcUserUnit()
const
2028 if (maxLen <= 14400)
2032 return qMin(maxLen / 14400.0, 75000.0);
2035void QPdfEnginePrivate::writeFonts()
2044void QPdfEnginePrivate::writePage()
2056 qreal userUnit = calcUserUnit();
2062 "/Contents %d 0 R\n"
2063 "/Resources %d 0 R\n"
2065 "/MediaBox [0 0 %s %s]\n",
2066 pageRoot, pageStream, resources, annots,
2077 addXrefEntry(resources);
2082 "/CSpg /DeviceGray\n"
2086 patternColorSpace, graphicsState);
2092 xprintf(
"/Pattern <<\n");
2097 xprintf(
"/Font <<\n");
2102 xprintf(
"/XObject <<\n");
2111 addXrefEntry(annots);
2116 xprintf(
"]\nendobj\n");
2118 addXrefEntry(pageStream);
2120 "/Length %d 0 R\n", pageStreamLength);
2122 xprintf(
"/Filter /FlateDecode\n");
2125 xprintf(
"stream\n");
2127 int len = writeCompressed(content);
2128 xprintf(
"\nendstream\n"
2131 addXrefEntry(pageStreamLength);
2132 xprintf(
"%d\nendobj\n",
len);
2141 writeAttachmentRoot();
2144 addXrefEntry(xrefPositions.
size(),
false);
2147 "%010d 65535 f \n", xrefPositions.
size()-1, xrefPositions[0]);
2149 for (
int i = 1;
i < xrefPositions.
size()-1; ++
i)
2150 xprintf(
"%010d 00000 n \n", xrefPositions[
i]);
2158 <<
"/Size " << xrefPositions.
size() - 1 <<
"\n"
2159 <<
"/Info " << info <<
"0 R\n"
2160 <<
"/Root " << catalog <<
"0 R\n";
2165 s <<
"/ID [ <" << fileIdentifier <<
"> <" << fileIdentifier <<
"> ]\n";
2169 <<
"startxref\n" << xrefPositions.
constLast() <<
"\n"
2176int QPdfEnginePrivate::addXrefEntry(
int object,
bool printostr)
2181 if (
object>=xrefPositions.
size())
2182 xrefPositions.
resize(
object+1);
2184 xrefPositions[
object] = streampos;
2186 xprintf(
"%d 0 obj\n",
object);
2191void QPdfEnginePrivate::printString(
QStringView string)
2193 if (
string.isEmpty()) {
2202 const char16_t *utf16 =
string.utf16();
2205 char part[2] = {char((*(utf16 +
i)) >> 8), char((*(utf16 +
i)) & 0xff)};
2206 for(
int j=0;
j < 2; ++
j) {
2207 if (part[
j] ==
'(' || part[
j] ==
')' || part[
j] ==
'\\')
2217void QPdfEnginePrivate::xprintf(
const char*
fmt, ...)
2222 const int msize = 10000;
2243int QPdfEnginePrivate::writeCompressed(
QIODevice *dev)
2245#ifndef QT_NO_COMPRESS
2250 zStruct.zalloc = Z_NULL;
2251 zStruct.zfree = Z_NULL;
2252 zStruct.opaque = Z_NULL;
2253 if (::deflateInit(&zStruct, Z_DEFAULT_COMPRESSION) != Z_OK) {
2254 qWarning(
"QPdfStream::writeCompressed: Error in deflateInit()");
2257 zStruct.avail_in = 0;
2260 while (!dev->
atEnd() || zStruct.avail_in != 0) {
2261 if (zStruct.avail_in == 0) {
2263 zStruct.avail_in =
in.size();
2264 zStruct.next_in =
reinterpret_cast<unsigned char*
>(
in.data());
2265 if (
in.size() <= 0) {
2266 qWarning(
"QPdfStream::writeCompressed: Error in read()");
2267 ::deflateEnd(&zStruct);
2271 zStruct.next_out =
reinterpret_cast<unsigned char*
>(
out.data());
2272 zStruct.avail_out =
out.size();
2274 qWarning(
"QPdfStream::writeCompressed: Error in deflate()");
2275 ::deflateEnd(&zStruct);
2278 int written =
out.size() - zStruct.avail_out;
2279 stream->writeRawData(
out.constData(), written);
2280 streampos += written;
2285 zStruct.next_out =
reinterpret_cast<unsigned char*
>(
out.data());
2286 zStruct.avail_out =
out.size();
2288 if (
ret != Z_OK &&
ret != Z_STREAM_END) {
2289 qWarning(
"QPdfStream::writeCompressed: Error in deflate()");
2290 ::deflateEnd(&zStruct);
2293 int written =
out.size() - zStruct.avail_out;
2294 stream->writeRawData(
out.constData(), written);
2295 streampos += written;
2297 }
while (
ret == Z_OK);
2299 ::deflateEnd(&zStruct);
2307 while (!dev->
atEnd()) {
2310 streampos += arr.
size();
2317int QPdfEnginePrivate::writeCompressed(
const char *
src,
int len)
2319#ifndef QT_NO_COMPRESS
2323 if (!
data.isNull()) {
2327 qWarning(
"QPdfStream::writeCompressed: Error in compress()");
2340 int maskObject,
int softMaskObject,
bool dct,
bool isMono)
2342 int image = addXrefEntry(-1);
2351 xprintf(
"/ImageMask true\n"
2354 xprintf(
"/BitsPerComponent 1\n"
2355 "/ColorSpace /DeviceGray\n");
2358 xprintf(
"/BitsPerComponent 8\n"
2359 "/ColorSpace %s\n", (
depth == 32) ?
"/DeviceRGB" :
"/DeviceGray");
2362 xprintf(
"/Mask %d 0 R\n", maskObject);
2363 if (softMaskObject > 0)
2364 xprintf(
"/SMask %d 0 R\n", softMaskObject);
2367 xprintf(
"/Length %d 0 R\n", lenobj);
2369 xprintf(
"/Interpolate true\n");
2373 xprintf(
"/Filter /DCTDecode\n>>\nstream\n");
2378 xprintf(
"/Filter /FlateDecode\n>>\nstream\n");
2380 xprintf(
">>\nstream\n");
2383 xprintf(
"\nendstream\n"
2385 addXrefEntry(lenobj);
2399int QPdfEnginePrivate::createShadingFunction(
const QGradient *gradient,
int from,
int to,
bool reflect,
bool alpha)
2406 if (stops.
at(0).first > 0)
2408 if (stops.
at(stops.
size() - 1).first < 1)
2412 const int numStops = stops.
size();
2413 functions.
reserve(numStops - 1);
2414 for (
int i = 0;
i < numStops - 1; ++
i) {
2415 int f = addXrefEntry(-1);
2423 s <<
"/C0 [" << stops.
at(
i).second.alphaF() <<
"]\n"
2424 "/C1 [" << stops.
at(
i + 1).second.alphaF() <<
"]\n";
2426 s <<
"/C0 [" << stops.
at(
i).second.redF() << stops.
at(
i).second.greenF() << stops.
at(
i).second.blueF() <<
"]\n"
2427 "/C1 [" << stops.
at(
i + 1).second.redF() << stops.
at(
i + 1).second.greenF() << stops.
at(
i + 1).second.blueF() <<
"]\n";
2436 gradientBounds.
reserve((to - from) * (numStops - 1));
2438 for (
int step = from; step < to; ++step) {
2439 if (reflect && step % 2) {
2440 for (
int i = numStops - 1;
i > 0; --
i) {
2444 b.function = functions.
at(
i - 1);
2446 gradientBounds <<
b;
2449 for (
int i = 0;
i < numStops - 1; ++
i) {
2453 b.function = functions.
at(
i);
2455 gradientBounds <<
b;
2461 qreal bstart = gradientBounds.
at(0).start;
2462 qreal bend = gradientBounds.
at(gradientBounds.
size() - 1).stop;
2463 qreal norm = 1./(bend - bstart);
2464 for (
int i = 0;
i < gradientBounds.
size(); ++
i) {
2465 gradientBounds[
i].start = (gradientBounds[
i].start - bstart)*norm;
2466 gradientBounds[
i].stop = (gradientBounds[
i].stop - bstart)*norm;
2470 if (gradientBounds.
size() > 1) {
2478 for (
int i = 1;
i < gradientBounds.
size(); ++
i)
2479 s << gradientBounds.
at(
i).start;
2482 for (
int i = 0;
i < gradientBounds.
size(); ++
i)
2483 s << (gradientBounds.
at(
i).reverse ?
"1 0 " :
"0 1 ");
2486 for (
int i = 0;
i < gradientBounds.
size(); ++
i)
2487 s << gradientBounds.
at(
i).function <<
"0 R ";
2507 bool reflect =
false;
2508 switch (gradient->
spread()) {
2529 for (
int i = 0;
i < 4; ++
i) {
2541 int function = createShadingFunction(gradient, from, to, reflect,
alpha);
2547 "/ColorSpace " << (
alpha ?
"/DeviceGray\n" :
"/DeviceRGB\n") <<
2549 "/Coords [" <<
start.x() <<
start.y() << stop.
x() << stop.
y() <<
"]\n"
2550 "/Extend [true true]\n"
2551 "/Function " <<
function <<
"0 R\n"
2554 int shaderObject = addXrefEntry(-1);
2556 return shaderObject;
2570 bool reflect =
false;
2571 switch (gradient->
spread()) {
2591 double radius = r0 + to*(
r1 - r0);
2592 double r2 = radius*radius;
2594 for (
int i = 0;
i < 4; ++
i) {
2596 if (off.
x()*off.
x() + off.
y()*off.
y() >
r2) {
2604 r1 = r0 + to*(
r1 - r0);
2609 int function = createShadingFunction(gradient, from, to, reflect,
alpha);
2615 "/ColorSpace " << (
alpha ?
"/DeviceGray\n" :
"/DeviceRGB\n") <<
2618 "/Coords [" << p0.
x() << p0.
y() << r0 <<
p1.x() <<
p1.y() <<
r1 <<
"]\n"
2619 "/Extend [true true]\n"
2620 "/Function " <<
function <<
"0 R\n"
2623 int shaderObject = addXrefEntry(-1);
2625 return shaderObject;
2630 switch (gradient->
type()) {
2654 int shaderObject = generateGradientShader(gradient,
m);
2661 "/Shading " << shaderObject <<
"0 R\n"
2672 int patternObj = addXrefEntry(-1);
2676 if (!
b.isOpaque()) {
2679 int a = stops.
at(0).second.alpha();
2680 for (
int i = 1;
i < stops.
size(); ++
i) {
2681 if (stops.
at(
i).second.alpha() !=
a) {
2689 int alphaShaderObject = generateGradientShader(gradient,
m,
true);
2693 c <<
"/Shader" << alphaShaderObject <<
"sh\n";
2700 "/BBox [0 0 " << pageRect.
width() << pageRect.
height() <<
"]\n"
2701 "/Group <</S /Transparency >>\n"
2703 "/Shading << /Shader" << alphaShaderObject << alphaShaderObject <<
"0 R >>\n"
2706 f <<
"/Length " << content.
size() <<
"\n"
2713 int softMaskFormObject = addXrefEntry(-1);
2715 *gStateObject = addXrefEntry(-1);
2716 xprintf(
"<< /SMask << /S /Alpha /G %d 0 R >> >>\n"
2717 "endobj\n", softMaskFormObject);
2727 if (brushAlpha == 255 && penAlpha == 255)
2731 object = addXrefEntry(-1);
2734 s <<
"<<\n/ca " << (brushAlpha/
qreal(255.)) <<
'\n';
2735 s <<
"/CA " << (penAlpha/
qreal(255.)) <<
"\n>>";
2736 xprintf(
"%s\nendobj\n", alphaDef.
constData());
2754 *specifyColor =
true;
2767 *specifyColor =
false;
2768 return gradientBrush(
brush,
matrix, gStateObject);
2778 int imageObject = -1;
2787 if (imageObject != -1) {
2791 *specifyColor =
false;
2798 s <<
"/Im" << imageObject <<
" Do\n";
2807 "/PaintType " << paintType <<
"\n"
2809 "/BBox [0 0 " <<
w <<
h <<
"]\n"
2810 "/XStep " <<
w <<
"\n"
2811 "/YStep " <<
h <<
"\n"
2820 if (imageObject > 0) {
2821 s <<
"/XObject << /Im" << imageObject <<
' ' << imageObject <<
"0 R >> ";
2824 "/Length " <<
pattern.size() <<
"\n"
2831 int patternObj = addXrefEntry(-1);
2839 return colorTable.
size() == 2
2853 int object = imageCache.
value(serial_no);
2861 if (
image.hasAlphaChannel()) {
2869 p.drawImage(0, 0,
image);
2871 image = alphaLessImage;
2893 int bytesPerLine = (
w + 7) >> 3;
2895 data.resize(bytesPerLine *
h);
2896 char *rawdata =
data.data();
2897 for (
int y = 0;
y <
h; ++
y) {
2898 memcpy(rawdata,
image.constScanLine(
y), bytesPerLine);
2899 rawdata += bytesPerLine;
2907 bool hasMask =
false;
2919 for (
int y = 0;
y <
h; ++
y) {
2921 for (
int x = 0;
x <
w; ++
x) {
2924 hasMask |= (
alpha < 255);
2935 for (
int y = 0;
y <
h; ++
y) {
2938 for (
int x = 0;
x <
w; ++
x) {
2942 hasMask |= (
alpha < 255);
2947 for (
int x = 0;
x <
w; ++
x) {
2953 hasMask |= (
alpha < 255);
2963 int softMaskObject = 0;
2965 softMaskObject = writeImage(softMaskData,
w,
h, 8, 0, 0);
2966 }
else if (hasMask) {
2969 int bytesPerLine = (
w + 7) >> 3;
2973 for (
int y = 0;
y <
h; ++
y) {
2974 for (
int x = 0;
x <
w; ++
x) {
2976 mdata[
x>>3] |= (0x80 >> (
x&7));
2979 mdata += bytesPerLine;
2981 maskObject = writeImage(
mask,
w,
h, 1, 0, 0);
2984 maskObject, softMaskObject, dct);
2986 imageCache.
insert(serial_no,
object);
2996 if (isLink || isAnchor) {
3017 uint annot = addXrefEntry(-1);
3019 x1s.
setNum(
static_cast<double>(
x1),
'f');
3020 y1s.
setNum(
static_cast<double>(
y1),
'f');
3021 x2s.
setNum(
static_cast<double>(
x2),
'f');
3022 y2s.
setNum(
static_cast<double>(
y2),
'f');
3023 QByteArray rectData = x1s +
' ' + y1s +
' ' + x2s +
' ' + y2s;
3024 xprintf(
"<<\n/Type /Annot\n/Subtype /Link\n");
3031#ifdef Q_DEBUG_PDF_LINKS
3032 xprintf(
"]\n/Border [16 16 1]\n");
3034 xprintf(
"]\n/Border [0 0 0]\n");
3044 printString(link.
sliced(1));
3048 xprintf(
"endobj\n");
3063 bool noEmbed =
false;
3069 q->QPaintEngine::drawTextItem(
p, ti);
3079 font->noEmbed = noEmbed;
3093 if (glyphs.
size() == 0)
3100 <<
"/F" <<
font->object_id <<
size <<
"Tf "
3102 ?
"0 .3 -1 0 0 Tm\n"
3103 :
"0 0 -1 0 0 Tm\n");
3108 const unsigned short *logClusters = ti.
logClusters;
3122 for (
int gs = logClusters[
pos]; gs < ge; ++gs)
3131 for (
int i = 0;
i < glyphs.
size(); ++
i) {
3146 ?
"0 .3 -1 0 0 Tm\n"
3147 :
"0 0 -1 0 0 Tm\n");
3148 *
currentPage <<
"/Span << /ActualText <> >> BDC\n";
3151 for (
int i = 0;
i < glyphs.
size(); ++
i) {
3173 qreal userUnit = calcUserUnit();
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Qt::BrushStyle style() const
Returns the brush style.
\inmodule QtCore \reentrant
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
void clear()
Clears the contents of the byte array and makes it null.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
The QColor class provides colors based on RGB, HSV or CMYK values.
float greenF() const noexcept
Returns the green color component of this color.
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
int alpha() const noexcept
Returns the alpha color component of this color.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
float redF() const noexcept
Returns the red color component of this color.
float blueF() const noexcept
Returns the blue color component of this color.
static QByteArray hash(QByteArrayView data, Algorithm method)
Returns the hash of data using method.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore \reentrant
int month() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int day() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
FileError error() const
Returns the file error status.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
virtual FaceId faceId() const
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
virtual QFixed lineThickness() const
virtual int synthesized() const
Spread spread() const
Returns the spread method use by this gradient.
CoordinateMode coordinateMode() const
Type type() const
Returns the type of gradient.
QGradientStops stops() const
Returns the stop points for this gradient.
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
T value(const Key &key) const noexcept
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
virtual bool reset()
Seeks to the start of input for random-access devices.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
The QImageWriter class provides a format independent interface for writing images to files or other d...
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageWriter.
void setQuality(int quality)
Sets the quality setting of the image format to quality.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
void fill(uint pixel)
Fills the entire image with the given pixelValue.
qint64 cacheKey() const
Returns a number that identifies the contents of this QImage object.
QPointF start() const
Returns the start point of this linear gradient in logical coordinates.
QPointF finalStop() const
Returns the final stop point of this linear gradient in logical coordinates.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
bool empty() const noexcept
const_reference at(qsizetype i) const noexcept
void prepend(rvalue_ref t)
void reserve(qsizetype size)
void resize(qsizetype size)
void append(parameter_type t)
QRect fullRectPoints() const
Returns the full page rectangle in Postscript Points (1/72 of an inch).
Mode mode() const
Returns the page layout mode.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
QRect paintRectPixels(int resolution) const
Returns the paintable rectangle in rounded device pixels for the given resolution.
Orientation
This enum type defines the page orientation.
QRect fullRectPixels(int resolution) const
Returns the full page rectangle in device pixels for the given resolution.
@ PdmDevicePixelRatioScaled
static qreal devicePixelRatioFScale()
The QPaintEngineState class provides information about the active paint engine's current state....
QTransform transform() const
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
QBrush brush() const
Returns the brush in the current paint engine state.
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
QPen pen() const
Returns the pen in the current paint engine state.
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
void setActive(bool newState)
Sets the active state of the paint engine to state.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
QPainter * painter() const
Returns the paint engine's painter.
@ ObjectBoundingModeGradients
QPaintEngineState * state
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Type
\value X11 \value Windows \value MacPrinter \value CoreGraphics \macos's Quartz2D (CoreGraphics) \val...
The QPainter class performs low-level painting on widgets and other paint devices.
@ NonCosmeticBrushPatterns
bool testRenderHint(RenderHint hint) const
QTransform pageMatrix() const
int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject)
int addConstantAlphaObject(int brushAlpha, int penAlpha=255)
int addImage(const QImage &image, bool *bitmap, bool lossless, qint64 serial_no)
Adds an image to the pdf and return the pdf-object id.
QHash< QFontEngine::FaceId, QFontSubset * > fonts
QPdfEngine::PdfVersion pdfVersion
void drawTextItem(const QPointF &p, const QTextItemInt &ti)
void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType)
QPageLayout pageLayout() const
void drawLines(const QLineF *lines, int lineCount) override
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
int metric(QPaintDevice::PaintDeviceMetric metricType) const
void setupGraphicsState(QPaintEngine::DirtyFlags flags)
void drawPixmap(const QRectF &rectangle, const QPixmap &pixmap, const QRectF &sr) override
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.
QByteArray documentXmpMetadata() const
void updateState(const QPaintEngineState &state) override
Reimplement this function to update the state of a paint engine.
void drawPoints(const QPointF *points, int pointCount) override
Draws the first pointCount points in the buffer points.
void drawRects(const QRectF *rects, int rectCount) override
Draws the first rectCount rectangles in the buffer rects.
Type type() const override
Reimplement this function to return the paint engine \l{Type}.
void setOutputFilename(const QString &filename)
void setPageOrientation(QPageLayout::Orientation orientation)
bool begin(QPaintDevice *pdev) override
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
void drawTextItem(const QPointF &p, const QTextItem &textItem) override
This function draws the text item textItem at position p.
bool end() override
Reimplement this function to finish painting on the current paint device.
void setPageMargins(const QMarginsF &margins, QPageLayout::Unit units=QPageLayout::Point)
void drawTiledPixmap(const QRectF &rectangle, const QPixmap &pixmap, const QPointF &point) override
Reimplement this function to draw the pixmap in the given rect, starting at the given p.
void setDocumentXmpMetadata(const QByteArray &xmpMetadata)
void drawPath(const QPainterPath &path) override
The default implementation ignores the path and does nothing.
void setPdfVersion(PdfVersion version)
void setPageLayout(const QPageLayout &pageLayout)
void drawHyperlink(const QRectF &r, const QUrl &url)
void setPageSize(const QPageSize &pageSize)
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor) override
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
void setResolution(int resolution)
void streamImage(int w, int h, uint object)
QList< uint > graphicStates
QList< uint > annotations
ByteStream & operator<<(char chr)
ByteStream(bool fileBacking=false)
void constructor_helper(QIODevice *dev)
static int maxMemorySize()
qreal widthF() const
Returns the pen width with floating point precision.
QList< qreal > dashPattern() const
Returns the dash pattern of this pen.
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
QColor color() const
Returns the color of this pen's brush.
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
void setColor(const QColor &color)
Sets the color of this pen's brush to the given color.
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
qreal miterLimit() const
Returns the miter limit of the pen.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
qreal dashOffset() const
Returns the dash offset for the pen.
Qt::PenStyle style() const
Returns the pen style.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
QImage toImage() const
Converts the pixmap to a QImage.
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr int x() const noexcept
Returns the x coordinate of this point.
QPointF center() const
Returns the center of this radial gradient in logical coordinates.
qreal focalRadius() const
QPointF focalPoint() const
Returns the focal point of this radial gradient in logical coordinates.
qreal centerRadius() const
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
The QRegion class specifies a clip region for a painter.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString sliced(qsizetype pos) const
QByteArray toUtf8() const &
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
QString toHtmlEscaped() const
void setCubicToHook(qStrokerCubicToHook cubicToHook)
void setMoveToHook(qStrokerMoveToHook moveToHook)
void setLineToHook(qStrokerLineToHook lineToHook)
void setStrokeWidth(qfixed width)
\inmodule QtCore \reentrant
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
QStringList anchorNames() const
QString anchorHref() const
Returns the text format's hypertext link, or an empty string if none has been set.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
const QTextCharFormat charFormat
const unsigned short * logClusters
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
int second() const
Returns the second part (0 to 59) of the time.
QByteArray toEncoded(FormattingOptions options=FullyEncoded) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
static QUuid createUuid()
On any platform other than Windows, this function returns a new UUID with variant QUuid::DCE and vers...
QString toString(StringFormat mode=WithBraces) const
constexpr size_type size() const noexcept
const T * constData() const
void reserve(qsizetype sz)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
const char * toHex(ushort u, char *buffer)
QByteArray generatePath(const QPainterPath &path, const QTransform &matrix, PathFlags flags)
QByteArray ascii85Encode(const QByteArray &input)
QByteArray generateDashes(const QPen &pen)
QByteArray patternForBrush(const QBrush &b)
QByteArray generateMatrix(const QTransform &matrix)
Combined button and popup list for selecting options.
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
QPair< qreal, QColor > QGradientStop
QByteArray qCompress(const uchar *data, qsizetype nbytes, int compressionLevel)
Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
std::pair< T1, T2 > QPair
AudioChannelLayoutTag tag
static const QCssKnownValue positions[NumKnownPositionModes - 1]
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
static QString header(const QString &name)
bool qFuzzyIsNull(qfloat16 f) noexcept
bool qIsNaN(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei const GLenum * attachments
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLenum GLsizeiptr const void * fontData
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLint GLint GLfixed points
GLfixed GLfixed GLfixed y2
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum mapping
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum GLenum GLenum scale
GLenum GLenum GLenum input
bool qt_isExtendedRadialGradient(const QBrush &brush)
const char * qt_int_to_string(int val, char *buf)
static void initResources()
static bool is_monochrome(const QList< QRgb > &colorTable)
static void removeTransparencyFromBrush(QBrush &brush)
static const char *const pattern_for_brush[]
static void lineToHook(qfixed x, qfixed y, void *data)
static const bool interpolateImages
static const bool do_compress
const char * qt_real_to_string(qreal val, char *buf)
QPainterPath qt_regionToPath(const QRegion ®ion)
static void moveToHook(qfixed x, qfixed y, void *data)
QPaintEngine::PaintEngineFeatures qt_pdf_decide_features()
static void cubicToHook(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey, void *data)
QT_BEGIN_NAMESPACE const char * qt_real_to_string(qreal val, char *buf)
static bool hasAlpha(const QImage &image)
static void grayscale(const QImage &image, QImage &dest, const QRect &rect=QRect())
static constexpr qint64 HeaderSize
QQuickAnchors * anchors(QQuickItem *item)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr int qGray(int r, int g, int b)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)
QT_BEGIN_NAMESPACE typedef qreal qfixed
#define Q_UNIMPLEMENTED()
#define Q_INIT_RESOURCE(name)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
QVideoFrameFormat::PixelFormat fmt
QT_BEGIN_NAMESPACE typedef uchar * output
static int deflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
QTextStream out(stdout)
[7]
QUrl url("example.com")
[constructor-url-reference]
constexpr qreal toReal() const
\inmodule QtCore \reentrant
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
bool contains(const AT &t) const noexcept
void setPen(const QPen &pen, QPainter::RenderHints hints)
void strokePath(const QPainterPath &path)