Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
georeferencer: disable the setting of 0 as nodata value by default, a…
…pply more robust version of if-statement in QgsRasterLayer::drawMultiBandColor

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7143 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 19, 2007
1 parent 9801067 commit 1b076b1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
7 changes: 1 addition & 6 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -2460,13 +2460,8 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
continue;
}

// TODO: check all channels ?
if ( myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble)
if((myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble) || (myGreenValueDouble == noDataValueDouble || myGreenValueDouble != myGreenValueDouble) || (myBlueValueDouble == noDataValueDouble || myBlueValueDouble != myBlueValueDouble))
{
#ifdef QGISDEBUG
// QgsLogger::debug("myRedValueDouble", myRedValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
// QgsLogger::debug("noDataValueDouble", noDataValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
#endif
continue;
}

Expand Down
9 changes: 3 additions & 6 deletions src/plugins/georeferencer/qgsgeorefwarpoptionsdialogbase.ui
@@ -1,15 +1,12 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QgsGeorefWarpOptionsDialogBase</class>
<widget class="QDialog" name="QgsGeorefWarpOptionsDialogBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>100</height>
<width>348</width>
<height>103</height>
</rect>
</property>
<property name="windowTitle" >
Expand Down Expand Up @@ -67,7 +64,7 @@
<string>Use 0 for transparency when needed</string>
</property>
<property name="checked" >
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
27 changes: 16 additions & 11 deletions src/plugins/georeferencer/qgsimagewarper.cpp
Expand Up @@ -66,18 +66,23 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
hSrcDS->GetRasterCount(),
hSrcDS->GetRasterBand(1)->GetRasterDataType(),
papszOptions);
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i) {
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
if (cTable)
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
if (noData != -1e10)
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
else if (useZeroAsTrans) {
std::cerr<<"***** Source raster has no NODATA value, using 0"<<std::endl;
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i)
{
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
if (cTable)
{
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
}
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
if (noData == -1e10 && useZeroAsTrans)
{
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
}
else
{
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
}
}
}
psWarpOptions->hDstDS = hDstDS;

// Initialize and execute the warp operation.
Expand Down

0 comments on commit 1b076b1

Please sign in to comment.