Feature #6802 » 0004-Add-transparency-support-to-WPdfImage.patch
src/Wt/WPdfImage.C | ||
---|---|---|
t.m22(), t.dx(), t.dy());
|
||
}
|
||
HPDF_ExtGState WPdfImage::setStrokeColor(WColor color)
|
||
{
|
||
HPDF_Page_SetRGBStroke(page_,
|
||
color.red() / 255.,
|
||
color.green() / 255.,
|
||
color.blue() / 255.);
|
||
auto it = alphaStrokeExtGStateMap_.find(color.alpha());
|
||
HPDF_ExtGState gstate;
|
||
if (it == alphaStrokeExtGStateMap_.end()) {
|
||
gstate = HPDF_CreateExtGState(pdf_);
|
||
HPDF_ExtGState_SetAlphaStroke (gstate, color.alpha()/255.);
|
||
alphaStrokeExtGStateMap_[color.alpha()] = gstate;
|
||
}
|
||
else {
|
||
gstate = it->second;
|
||
}
|
||
HPDF_Page_SetExtGState (page_, gstate);
|
||
}
|
||
HPDF_ExtGState WPdfImage::setFillColor(WColor color)
|
||
{
|
||
HPDF_Page_SetRGBFill(page_,
|
||
color.red() / 255.,
|
||
color.green() / 255.,
|
||
color.blue() / 255.);
|
||
auto it = alphaFillExtGStateMap_.find(color.alpha());
|
||
HPDF_ExtGState gstate;
|
||
if (it == alphaFillExtGStateMap_.end()) {
|
||
gstate = HPDF_CreateExtGState(pdf_);
|
||
HPDF_ExtGState_SetAlphaFill (gstate, color.alpha()/255.);
|
||
alphaFillExtGStateMap_[color.alpha()] = gstate;
|
||
}
|
||
else {
|
||
gstate = it->second;
|
||
}
|
||
HPDF_Page_SetExtGState (page_, gstate);
|
||
}
|
||
void WPdfImage::setChanged(WFlags<PainterChangeFlag> flags)
|
||
{
|
||
if (!(flags & (PainterChangeFlag::Transform | PainterChangeFlag::Clipping)).empty()) {
|
||
... | ... | |
if (pen.style() != PenStyle::None) {
|
||
const WColor& color = pen.color();
|
||
HPDF_Page_SetRGBStroke(page_,
|
||
color.red() / 255.,
|
||
color.green() / 255.,
|
||
color.blue() / 255.);
|
||
setStrokeColor(color);
|
||
WLength w = painter()->normalizedPenWidth(pen.width(), false);
|
||
HPDF_Page_SetLineWidth(page_, w.toPixels());
|
||
... | ... | |
if (brush.style() != BrushStyle::None) {
|
||
const WColor& color = painter()->brush().color();
|
||
HPDF_Page_SetRGBFill(page_,
|
||
color.red() / 255.,
|
||
color.green() / 255.,
|
||
color.blue() / 255.);
|
||
setFillColor(color);
|
||
}
|
||
}
|
||
... | ... | |
HPDF_Page_GSave(page_);
|
||
// Need to fill text using pen color
|
||
const WColor& penColor = painter()->pen().color();
|
||
setFillColor(penColor);
|
||
// Undo the global inversion
|
||
HPDF_Page_Concat(page_, 1, 0, 0, -1, 0, bottom);
|
||
HPDF_Page_BeginText(page_);
|
||
// Need to fill text using pen color
|
||
const WColor& penColor = painter()->pen().color();
|
||
HPDF_Page_SetRGBFill(page_,
|
||
penColor.red() / 255.,
|
||
penColor.green() / 255.,
|
||
penColor.blue() / 255.);
|
||
std::string s = trueTypeFont_ ? text.toUTF8() : text.narrow();
|
||
HPDF_Page_TextRect(page_, left, fontSize_, right, 0, s.c_str(),
|
src/Wt/WPdfImage.h | ||
---|---|---|
#ifndef WPDF_IMAGE_H_
|
||
#define WPDF_IMAGE_H_
|
||
#include <unordered_map>
|
||
#include <Wt/WFont.h>
|
||
#include <Wt/WPaintDevice.h>
|
||
#include <Wt/WResource.h>
|
||
... | ... | |
std::map<std::string, const char *> ttfFonts_;
|
||
WFont currentFont_;
|
||
std::string currentTtfFont_;
|
||
std::unordered_map<int, HPDF_ExtGState> alphaStrokeExtGStateMap_;
|
||
std::unordered_map<int, HPDF_ExtGState> alphaFillExtGStateMap_;
|
||
bool myPdf_;
|
||
double x_, y_;
|
||
... | ... | |
void paintPath();
|
||
void drawPlainPath(const WPainterPath& path);
|
||
void applyTransform(const WTransform& f);
|
||
HPDF_ExtGState setStrokeColor(WColor color);
|
||
HPDF_ExtGState setFillColor(WColor color);
|
||
};
|
||
}
|