1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Compare commits

..

2 Commits

Author SHA1 Message Date
af7696bfd7 Do the hillshading in alpha layer only 2024-02-26 10:27:58 +01:00
f3bb7ada9a Split the alpha and z values 2024-02-26 09:10:38 +01:00
2 changed files with 4 additions and 5 deletions

View File

@ -59,8 +59,8 @@ static void getSubmatrix(int x, int y, const Matrix &m, SubMatrix &sm)
sm.z9 = m.m(bottom, right); sm.z9 = m.m(bottom, right);
} }
QImage HillShading::render(const Matrix &m, quint8 alpha, double azimuth, QImage HillShading::render(const Matrix &m, quint8 alpha, double z,
double elevation) double azimuth, double elevation)
{ {
QImage img(m.w() - 2, m.h() - 2, QImage::Format_ARGB32_Premultiplied); QImage img(m.w() - 2, m.h() - 2, QImage::Format_ARGB32_Premultiplied);
uchar *bits = img.bits(); uchar *bits = img.bits();
@ -69,7 +69,6 @@ QImage HillShading::render(const Matrix &m, quint8 alpha, double azimuth,
Constants c; Constants c;
SubMatrix sm; SubMatrix sm;
Derivatives d; Derivatives d;
double z = (double)alpha / 0xFF;
getConstants(azimuth, elevation, c); getConstants(azimuth, elevation, c);
@ -86,7 +85,7 @@ QImage HillShading::render(const Matrix &m, quint8 alpha, double azimuth,
pixel = 0; pixel = 0;
else { else {
quint8 val = (L < 0) ? 0 : L * alpha; quint8 val = (L < 0) ? 0 : L * alpha;
pixel = alpha<<24 | val<<16 | val<<8 | val; pixel = (alpha - val)<<24;
} }
*(quint32*)(bits + (y - 1) * bpl + (x - 1) * 4) = pixel; *(quint32*)(bits + (y - 1) * bpl + (x - 1) * 4) = pixel;

View File

@ -7,7 +7,7 @@
class HillShading class HillShading
{ {
public: public:
static QImage render(const Matrix &m, quint8 alpha = 64, static QImage render(const Matrix &m, quint8 alpha = 64, double z = 0.3,
double azimuth = 315, double elevation = 25); double azimuth = 315, double elevation = 25);
}; };