1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-04-21 12:49:10 +02:00

Compare commits

..

No commits in common. "9464bbc13f3d5766d2466dee6208442aca058055" and "96b602bf140f9e3690fac830a71046824f909cc9" have entirely different histories.

2 changed files with 9 additions and 18 deletions

View File

@ -326,10 +326,10 @@ void Style::defaultLineStyle(qreal ratio)
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x07)] = Line(QPen(QColor("#ffffff"), 2, Qt::SolidLine), _lines[TYPE(0x07)] = Line(QPen(QColor("#ffffff"), 2, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x08)] = Line(QPen(QColor("#faef75"), 3, Qt::SolidLine), _lines[TYPE(0x08)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#dbd27b"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x09)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x09)] = Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine),
QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x0a)] = Line(QPen(QColor("#aba083"), 1, Qt::DashLine)); _lines[TYPE(0x0a)] = Line(QPen(QColor("#aba083"), 1, Qt::DashLine));
_lines[TYPE(0x0b)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine), _lines[TYPE(0x0b)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

View File

@ -4,10 +4,11 @@
#include "bitmapline.h" #include "bitmapline.h"
static QImage img2line(const QImage &img, int width, int offset) static QImage img2line(const QImage &img, int width)
{ {
Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied); Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied);
QImage res(width, img.height(), QImage::Format_ARGB32_Premultiplied); QImage res(width * img.devicePixelRatio(), img.height(),
QImage::Format_ARGB32_Premultiplied);
const int srcBpl = img.bytesPerLine(); const int srcBpl = img.bytesPerLine();
const int dstBpl = res.bytesPerLine(); const int dstBpl = res.bytesPerLine();
const uchar *srcBits = img.bits(); const uchar *srcBits = img.bits();
@ -16,14 +17,8 @@ static QImage img2line(const QImage &img, int width, int offset)
for (int i = 0; i < img.height(); i++) { for (int i = 0; i < img.height(); i++) {
const uchar *srcLine = srcBits + srcBpl * i; const uchar *srcLine = srcBits + srcBpl * i;
uchar *dstLine = dstBits + dstBpl * i; uchar *dstLine = dstBits + dstBpl * i;
int size = 0;
if (offset) { for (int j = dstBpl; j > 0; j -= srcBpl, dstLine += srcBpl)
size = qMin(dstBpl, srcBpl - 4 * offset);
memcpy(dstLine, srcLine + 4 * offset, size);
dstLine += size;
}
for (int j = dstBpl - size; j > 0; j -= srcBpl, dstLine += srcBpl)
memcpy(dstLine, srcLine, qMin(j, srcBpl)); memcpy(dstLine, srcLine, qMin(j, srcBpl));
} }
@ -35,20 +30,16 @@ static QImage img2line(const QImage &img, int width, int offset)
void BitmapLine::draw(QPainter *painter, const QPolygonF &line, void BitmapLine::draw(QPainter *painter, const QPolygonF &line,
const QImage &img) const QImage &img)
{ {
int offset = 0;
for (int i = 1; i < line.size(); i++) { for (int i = 1; i < line.size(); i++) {
QLineF segment(line.at(i-1).x(), line.at(i-1).y(), line.at(i).x(), QLineF segment(line.at(i-1).x(), line.at(i-1).y(), line.at(i).x(),
line.at(i).y()); line.at(i).y());
int len = qCeil(segment.length() * img.devicePixelRatio());
painter->save(); painter->save();
painter->translate(segment.p1()); painter->translate(segment.p1());
painter->rotate(-segment.angle()); painter->rotate(-segment.angle());
painter->drawImage(0.0, -img.height()/2.0, img2line(img, len, offset)); painter->drawImage(0.0, -img.height()/2.0, img2line(img,
qCeil(segment.length())));
painter->restore(); painter->restore();
offset = (len + offset) % img.width();
} }
} }