[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble
From:       Torsten Rahn <tackat () kde ! org>
Date:       2008-02-11 12:28:52
Message-ID: 1202732932.200003.23204.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 773569 by rahn:

2008-02-11  Torsten Rahn  <rahn@kde.org>

    * data/CMakeLists.txt:
    * src/lib/TextureColorizer.{cpp,h}:
    * src/lib/texturepalette.cpp: deleted

    Patch by Ismael Asensio to make marble use the .leg files 
    instead of using the hardcoded values in texturepalette.cpp.




 M  +9 -0      ChangeLog  
 M  +4 -0      data/CMakeLists.txt  
 M  +69 -3     src/lib/TextureColorizer.cpp  
 M  +7 -2      src/lib/TextureColorizer.h  
 D             src/lib/texturepalette.cpp  


--- trunk/KDE/kdeedu/marble/ChangeLog #773568:773569
@@ -1,3 +1,12 @@
+2008-02-11  Torsten Rahn  <rahn@kde.org>
+
+    * data/CMakeLists.txt:
+    * src/lib/TextureColorizer.{cpp,h}:
+    * src/lib/texturepalette.cpp: deleted
+
+    Patch by Ismael Asensio to make marble use the .leg files 
+    instead of using the hardcoded values in texturepalette.cpp.
+
 2008-02-10  Inge Wallin  <inge@lysator.liu.se>
 
 	Fix issue with integer overflow and some cleaning
--- trunk/KDE/kdeedu/marble/data/CMakeLists.txt #773568:773569
@@ -5,6 +5,10 @@
 legend.css
 DESTINATION ${MARBLE_DATA_PATH})
 
+FILE (GLOB LEGEND_FILES *.leg)
+install (FILES ${LEGEND_FILES}
+DESTINATION ${MARBLE_DATA_PATH})
+
 FILE (GLOB BITMAP_FILES bitmaps/*.png)
 install (FILES ${BITMAP_FILES}
 DESTINATION ${MARBLE_DATA_PATH}/bitmaps)
--- trunk/KDE/kdeedu/marble/src/lib/TextureColorizer.cpp #773568:773569
@@ -19,14 +19,16 @@
 
 #include "global.h"
 #include "ViewParams.h"
-#include "texturepalette.cpp"
 
+uint TextureColorizer::texturepalette[16][512];
 
 TextureColorizer::TextureColorizer( const QString& seafile, 
                                     const QString& landfile )
 {
-    Q_UNUSED( seafile );
-    Q_UNUSED( landfile );
+//    Q_UNUSED( seafile );
+//    Q_UNUSED( landfile );
+
+   generatePalette(seafile, landfile);
 }
 
 void TextureColorizer::colorize(ViewParams *viewParams)
@@ -161,4 +163,68 @@
     }
 }
 
+void TextureColorizer::generatePalette(const QString& seafile, const QString& landfile) const
+{    
 
+    //Text copy/pasted from tools/palettegen.cpp 
+
+    QImage  *gradimg = new QImage( 256, 10, QImage::Format_RGB32 );
+
+    QStringList  filelist;
+    filelist << seafile << landfile;
+    QString  filename;
+
+    QPainter  painter(gradimg);
+    painter.setPen(Qt::NoPen);
+
+    for ( int j = 0; j < 16; ++j ) {
+  
+        int offset = 0;
+
+        foreach ( filename, filelist ) {
+	
+            QLinearGradient  gradient( 0, 0, 256, 0 );
+
+            QFile  file( filename );
+            file.open( QIODevice::ReadOnly );
+            QTextStream  stream( &file );  // read the data serialized from the file
+            QString  evalstrg;
+
+            while ( !stream.atEnd() ) {
+                stream >> evalstrg;
+                if ( !evalstrg.isEmpty() && evalstrg.contains( "=" ) ) {
+                    QString  colval = evalstrg.section( "=", 0, 0 );
+                    QString  colpos = evalstrg.section( "=", 1, 1 );
+                    gradient.setColorAt(colpos.toDouble(), QColor(colval));
+                }
+            }
+            painter.setBrush( gradient );
+            painter.drawRect( 0, 0, 256, 10 );	
+
+            int  alpha = j;
+
+            for ( int i = 0; i < 256; ++i) {
+
+                    QRgb  shadeColor = gradimg->pixel( i, 1 );
+                    QImage  shadeImage ( 256, 10, QImage::Format_RGB32 );
+                    QLinearGradient  shadeGradient( 0, 0, 256, 0 );
+                    shadeGradient.setColorAt(0.15, QColor(Qt::white));
+                    shadeGradient.setColorAt(0.496, shadeColor);
+                    shadeGradient.setColorAt(0.504, shadeColor);
+                    shadeGradient.setColorAt(0.75, QColor(Qt::black));
+                    QPainter  shadePainter(&shadeImage);
+                    shadePainter.setPen(Qt::NoPen);
+                    shadePainter.setBrush( shadeGradient );
+                    shadePainter.drawRect( 0, 0, 256, 10 );  
+                    int shadeIndex = 120 + alpha;
+//                    qDebug() << QString("Shade: %1").arg(shadeIndex);
+                    QRgb  palcol = shadeImage.pixel( shadeIndex, 1 );
+
+                // populate texturepalette[][]
+                texturepalette[j][offset + i] = (uint)palcol;
+            }
+
+            offset += 256;
+        }
+    }
+}
--- trunk/KDE/kdeedu/marble/src/lib/TextureColorizer.h #773568:773569
@@ -21,7 +21,12 @@
 #include <QtCore/QString>
 #include <QtCore/QList>
 #include <QtCore/QVector>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+//#include <QtCore/QTextStream>
+#include <QtCore/QStringList>
 #include <QtGui/QImage>
+#include <QtGui/QPainter>
 
 #include "Quaternion.h"
 
@@ -52,8 +57,8 @@
     void colorize(ViewParams *viewParams);
 
  private:
-    static const uint  texturepalette[][512];
+    static uint texturepalette[16][512];
+    void generatePalette(const QString& seafile, const QString& landfile) const;
 };
 
-
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic