Skip to content

Commit

Permalink
Added option to choose compression method for helmert-transformed tif…
Browse files Browse the repository at this point in the history
… file

git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@7144 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 19, 2007
1 parent f3371e1 commit cce3ca8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
10 changes: 9 additions & 1 deletion src/plugins/georeferencer/qgsgeorefwarpoptionsdialog.cpp
Expand Up @@ -6,14 +6,22 @@ QgsGeorefWarpOptionsDialog::QgsGeorefWarpOptionsDialog(QWidget* parent)
: QgsGeorefWarpOptionsDialogBase()
{
setupUi(this);
QStringList compressionMethods;
compressionMethods << "LZW";
compressionMethods << "PACKBITS";
compressionMethods << "DEFLATE";
compressionMethods << "NONE";
mCompressionComboBox->addItems(compressionMethods);
}


void QgsGeorefWarpOptionsDialog::
getWarpOptions(QgsImageWarper::ResamplingMethod& resampling,
bool& useZeroForTransparency) {
bool& useZeroForTransparency, QString& compression)
{
resampling = this->resampling;
useZeroForTransparency = this->useZeroAsTransparency;
compression = mCompressionComboBox->currentText();
}


Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsgeorefwarpoptionsdialog.h
Expand Up @@ -24,7 +24,7 @@ Q_OBJECT

QgsGeorefWarpOptionsDialog(QWidget* parent);
void getWarpOptions(QgsImageWarper::ResamplingMethod& resampling,
bool& useZeroForTransparency);
bool& useZeroForTransparency, QString& compression);

public slots:

Expand Down
36 changes: 23 additions & 13 deletions src/plugins/georeferencer/qgsgeorefwarpoptionsdialogbase.ui
Expand Up @@ -5,20 +5,30 @@
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>103</height>
<width>366</width>
<height>130</height>
</rect>
</property>
<property name="windowTitle" >
<string>Warp options</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>10</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" colspan="2" >
<widget class="QComboBox" name="mCompressionComboBox" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="mCompressionLabel" >
<property name="text" >
<string>Compression:</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
Expand Down Expand Up @@ -48,23 +58,23 @@
</item>
</widget>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="pbnOK" >
<item row="2" column="0" colspan="2" >
<widget class="QCheckBox" name="cbxZeroAsTrans" >
<property name="text" >
<string>OK</string>
<string>Use 0 for transparency when needed</string>
</property>
<property name="default" >
<bool>true</bool>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QCheckBox" name="cbxZeroAsTrans" >
<item row="2" column="2" >
<widget class="QPushButton" name="pbnOK" >
<property name="text" >
<string>Use 0 for transparency when needed</string>
<string>OK</string>
</property>
<property name="checked" >
<bool>false</bool>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/georeferencer/qgsimagewarper.cpp
Expand Up @@ -14,7 +14,7 @@

void QgsImageWarper::warp(const QString& input, const QString& output,
double& xOffset, double& yOffset,
ResamplingMethod resampling, bool useZeroAsTrans) {
ResamplingMethod resampling, bool useZeroAsTrans, const QString& compression) {
// Open input file
GDALAllRegister();
GDALDataset* hSrcDS = static_cast<GDALDataset*>(GDALOpen(QFile::encodeName(input).constData(),
Expand Down Expand Up @@ -61,6 +61,7 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
GDALDriver* driver = static_cast<GDALDriver*>(GDALGetDriverByName("GTiff"));
char **papszOptions = NULL;
papszOptions = CSLSetNameValue(papszOptions, "INIT_DEST", "NO_DATA");
papszOptions = CSLSetNameValue(papszOptions, "COMPRESS", compression);
GDALDataset* hDstDS =
driver->Create(QFile::encodeName(output).constData(), newXSize, newYSize,
hSrcDS->GetRasterCount(),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsimagewarper.h
Expand Up @@ -19,7 +19,7 @@ class QgsImageWarper {

void warp(const QString& input, const QString& output,
double& xOffset, double& yOffset,
ResamplingMethod resampling = Bilinear, bool useZeroAsTrans = true);
ResamplingMethod resampling = Bilinear, bool useZeroAsTrans = true, const QString& compression = "NONE");

private:

Expand Down
5 changes: 3 additions & 2 deletions src/plugins/georeferencer/qgspointdialog.cpp
Expand Up @@ -367,11 +367,12 @@ bool QgsPointDialog::generateWorldFile()
QgsGeorefWarpOptionsDialog d(this);
d.exec();
bool useZeroForTrans;
QString compressionMethod;
QgsImageWarper::ResamplingMethod resampling;
QgsImageWarper warper(-rotation);
d.getWarpOptions(resampling, useZeroForTrans);
d.getWarpOptions(resampling, useZeroForTrans, compressionMethod);
warper.warp(mLayer->source(), outputFileName,
xOffset, yOffset, resampling, useZeroForTrans);
xOffset, yOffset, resampling, useZeroForTrans, compressionMethod);
}

// write the world file
Expand Down

0 comments on commit cce3ca8

Please sign in to comment.