Am 09.11.2014 um 20:52 schrieb Kay F. Jahnke:

The documentation shows me that QImage supports alpha channels. So the
way to go would be to have the map all black and assign the calculated
hillshade to the alpha channel instead of the pixel's grey value. If I
understand the docu right, you can continue using the same QImage you
make, and could use a coulour table. The coulour table's entries can be
ARGB values, so you can let the transparency correspond with the value
in the QImage by assigning

0 -> 0, 0, 0, 0
1 -> 1, 0, 0, 0
...
255 -> 255, 0, 0.

I tried a quick hack, but failed

okay, here you go, quick hack, couldn't figure out how to initialize only once, sure you can do better:


static QVector<QRgb> colourmap ( 256 ) ;

void IDem::hillshading(QVector<qint16>& data, qreal w, qreal h, QImage& img)
{
    int wp2 = w + 2;
    qint16 win[9];
    qreal dx, dy, aspect, xx_plus_yy, cang;
    for ( int i = 0 ; i < 256 ; i++ )
        colourmap[i] = qRgba(0, 0, 0, 255 - i) ;
...
    img.setColorTable ( colourmap );
}

find patch attached

Kay
diff -r 8c504fe90558 CMakeLists.txt
--- a/CMakeLists.txt	Tue Nov 04 21:49:51 2014 +0100
+++ b/CMakeLists.txt	Sun Nov 09 21:12:27 2014 +0100
@@ -4,9 +4,15 @@
 
 # has to be removed later on
 
+# <<<<<<< local
+# if(UNIX)
+# set(CMAKE_PREFIX_PATH /opt/Qt/5.3/gcc_64)
+# endif(UNIX)
+# =======
 if(UNIX)
-set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /opt/Qt/5.3/gcc_64)
+set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /home/kfj/Qt/5.3/gcc_64) # /opt/Qt/5.3/gcc_64)
 endif(UNIX)
+# >>>>>>> other
 
 
 if(WIN32)
diff -r 8c504fe90558 qmapshack.desktop
--- a/qmapshack.desktop	Tue Nov 04 21:49:51 2014 +0100
+++ b/qmapshack.desktop	Sun Nov 09 21:12:27 2014 +0100
@@ -1,3 +1,4 @@
+#!/usr/bin/env xdg-open
 [Desktop Entry]
 Version=1.0
 Name=QMapShack
diff -r 8c504fe90558 src/dem/IDem.cpp
--- a/src/dem/IDem.cpp	Tue Nov 04 21:49:51 2014 +0100
+++ b/src/dem/IDem.cpp	Sun Nov 09 21:12:27 2014 +0100
@@ -124,12 +124,16 @@
         return factorHillshading;
     }
 }
+    ;
+static QVector<QRgb> colourmap ( 256 ) ;
 
 void IDem::hillshading(QVector<qint16>& data, qreal w, qreal h, QImage& img)
 {
     int wp2 = w + 2;
     qint16 win[9];
     qreal dx, dy, aspect, xx_plus_yy, cang;
+    for ( int i = 0 ; i < 256 ; i++ )
+        colourmap[i] = qRgba(0, 0, 0, 255 - i) ;
 
 #define ZFACT           0.125
 #define ZFACT_BY_ZFACT  (ZFACT*ZFACT)
@@ -159,6 +163,7 @@
             img.setPixel(n - 1, m - 1, cang);
         }
     }
+    img.setColorTable ( colourmap );
 }
 
 
------------------------------------------------------------------------------
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users

Reply via email to