Add ui tool temporarily called main...
This commit is contained in:
parent
f78c32a383
commit
eb96117989
@ -26,7 +26,10 @@
|
||||
|
||||
#include <nvcore/Debug.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> // stderr
|
||||
#include <stdlib.h> // exit
|
||||
#include <stdarg.h> // va_list
|
||||
|
||||
|
||||
struct MyMessageHandler : public nv::MessageHandler {
|
||||
MyMessageHandler() {
|
||||
|
@ -44,7 +44,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
||||
|
||||
virtual void setTotal(int t)
|
||||
{
|
||||
total = t;
|
||||
total = t + 128;
|
||||
}
|
||||
virtual void setDisplayProgress(bool b)
|
||||
{
|
||||
@ -375,7 +375,7 @@ int main(int argc, char *argv[])
|
||||
//compressionOptions.setQuality(nvtt::Quality_Production, 0.5f);
|
||||
//compressionOptions.setQuality(nvtt::Quality_Highest);
|
||||
}
|
||||
compressionOptions.enableHardwareCompression(!nocuda);
|
||||
compressionOptions.enableCudaCompression(!nocuda);
|
||||
compressionOptions.setColorWeights(1, 1, 1);
|
||||
|
||||
if (externalCompressor != NULL)
|
||||
@ -395,8 +395,10 @@ int main(int argc, char *argv[])
|
||||
outputHandler.setTotal(nvtt::estimateSize(inputOptions, compressionOptions));
|
||||
outputHandler.setDisplayProgress(!silent);
|
||||
|
||||
nvtt::OutputOptions outputOptions(&outputHandler, &errorHandler);
|
||||
//nvtt::OutputOptions outputOptions(NULL, &errorHandler);
|
||||
nvtt::OutputOptions outputOptions;
|
||||
//outputOptions.setFileName(output);
|
||||
outputOptions.setOutputHandler(&outputHandler);
|
||||
outputOptions.setErrorHandler(&errorHandler);
|
||||
|
||||
// printf("Press ENTER.\n");
|
||||
// fflush(stdout);
|
||||
|
@ -23,9 +23,138 @@
|
||||
|
||||
#include "configdialog.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <QtGui/QImage>
|
||||
|
||||
|
||||
ConfigDialog::ConfigDialog(QWidget *parent/*=0*/) : QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
init();
|
||||
}
|
||||
|
||||
ConfigDialog::ConfigDialog(const char * fileName, QWidget *parent/*=0*/) : QDialog(parent)
|
||||
{
|
||||
init();
|
||||
|
||||
open(fileName);
|
||||
}
|
||||
|
||||
void ConfigDialog::init()
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.openButton, SIGNAL(clicked()), this, SLOT(openClicked()));
|
||||
connect(ui.generateMipmapsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(generateMipmapsChanged(int)));
|
||||
connect(ui.mipmapFilterComboBox, SIGNAL(activated(QString)), this, SLOT(mipmapFilterChanged(QString)));
|
||||
//connect(ui.mipmapFilterSettings, SIGNAL(clicked()), this, SLOT(mipmapFilterSettingsShow()));
|
||||
|
||||
connect(ui.redSpinBox, SIGNAL(valueChanged(double)), this, SLOT(colorWeightChanged()));
|
||||
connect(ui.greenSpinBox, SIGNAL(valueChanged(double)), this, SLOT(colorWeightChanged()));
|
||||
connect(ui.blueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(colorWeightChanged()));
|
||||
connect(ui.uniformButton, SIGNAL(toggled(bool)), this, SLOT(uniformWeightToggled(bool)));
|
||||
connect(ui.luminanceButton, SIGNAL(toggled(bool)), this, SLOT(luminanceWeightToggled(bool)));
|
||||
}
|
||||
|
||||
|
||||
void ConfigDialog::openClicked()
|
||||
{
|
||||
// @@ Open file dialog.
|
||||
|
||||
QString fileName;
|
||||
|
||||
open(fileName);
|
||||
}
|
||||
|
||||
void ConfigDialog::generateMipmapsChanged(int state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
|
||||
bool generateMipmapEnabled = ui.generateMipmapsCheckBox->isChecked();
|
||||
|
||||
ui.mipmapFilterLabel->setEnabled(generateMipmapEnabled);
|
||||
ui.mipmapFilterComboBox->setEnabled(generateMipmapEnabled);
|
||||
ui.limitMipmapsCheckBox->setEnabled(generateMipmapEnabled);
|
||||
|
||||
bool enableFilterSettings = (ui.mipmapFilterComboBox->currentText() == "Kaiser");
|
||||
ui.mipmapFilterSettings->setEnabled(generateMipmapEnabled && enableFilterSettings);
|
||||
|
||||
bool enableMaxLevel = ui.limitMipmapsCheckBox->isChecked();
|
||||
ui.maxLevelLabel->setEnabled(generateMipmapEnabled && enableMaxLevel);
|
||||
ui.maxLevelSpinBox->setEnabled(generateMipmapEnabled && enableMaxLevel);
|
||||
}
|
||||
|
||||
void ConfigDialog::mipmapFilterChanged(QString name)
|
||||
{
|
||||
bool enableFilterSettings = (name == "Kaiser");
|
||||
ui.mipmapFilterSettings->setEnabled(enableFilterSettings);
|
||||
}
|
||||
|
||||
|
||||
void ConfigDialog::colorWeightChanged()
|
||||
{
|
||||
double r = ui.redSpinBox->value();
|
||||
double g = ui.greenSpinBox->value();
|
||||
double b = ui.blueSpinBox->value();
|
||||
|
||||
bool uniform = (r == 1.0 && g == 1.0 && b == 1.0);
|
||||
bool luminance = (r == 0.3 && g == 0.59 && b == 0.11);
|
||||
|
||||
ui.uniformButton->setChecked(uniform);
|
||||
ui.luminanceButton->setChecked(luminance);
|
||||
}
|
||||
|
||||
void ConfigDialog::uniformWeightToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
ui.redSpinBox->setValue(1.0);
|
||||
ui.greenSpinBox->setValue(1.0);
|
||||
ui.blueSpinBox->setValue(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigDialog::luminanceWeightToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
ui.redSpinBox->setValue(0.3);
|
||||
ui.greenSpinBox->setValue(0.59);
|
||||
ui.blueSpinBox->setValue(0.11);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ConfigDialog::open(QString fileName)
|
||||
{
|
||||
// @@ Load image.
|
||||
QImage image;
|
||||
|
||||
// @@ If success.
|
||||
{
|
||||
ui.imagePathLineEdit->setText(fileName);
|
||||
|
||||
// @@ Set image in graphics view.
|
||||
|
||||
// @@ Set image description.
|
||||
|
||||
// @@ Provide image to nvtt.
|
||||
|
||||
int w = image.width();
|
||||
int h = image.height();
|
||||
void * data = NULL;
|
||||
|
||||
inputOptions.setTextureLayout(nvtt::TextureType_2D, w, h);
|
||||
inputOptions.setMipmapData(data, w, h);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -26,17 +26,42 @@
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
#include "ui_nvdxtdialog.h"
|
||||
#include "ui_configdialog.h"
|
||||
|
||||
#include <nvtt/nvtt.h>
|
||||
|
||||
|
||||
class ConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigDialog(QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
Ui::ConfigDialog ui;
|
||||
public:
|
||||
ConfigDialog(QWidget *parent = 0);
|
||||
ConfigDialog(const char * fileName, QWidget *parent = 0);
|
||||
|
||||
protected slots:
|
||||
|
||||
void openClicked();
|
||||
void generateMipmapsChanged(int state);
|
||||
void mipmapFilterChanged(QString name);
|
||||
|
||||
void colorWeightChanged();
|
||||
void uniformWeightToggled(bool checked);
|
||||
void luminanceWeightToggled(bool checked);
|
||||
|
||||
|
||||
bool open(QString fileName);
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
|
||||
private:
|
||||
Ui::ConfigDialog ui;
|
||||
|
||||
nvtt::InputOptions inputOptions;
|
||||
nvtt::CompressionOptions compressionOptions;
|
||||
nvtt::OutputOptions outputOptions;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
34
src/nvtt/tools/main.cpp
Normal file
34
src/nvtt/tools/main.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "configdialog.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
ConfigDialog dialog;
|
||||
return dialog.exec();
|
||||
}
|
||||
|
||||
|
@ -84,14 +84,14 @@ int main(int argc, char *argv[])
|
||||
if (strcmp("-s", argv[i]) == 0)
|
||||
{
|
||||
if (i+1 < argc && argv[i+1][0] != '-') {
|
||||
scale = (float)atof(argv[i+1]);
|
||||
scale = atof(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if (strcmp("-g", argv[i]) == 0)
|
||||
{
|
||||
if (i+1 < argc && argv[i+1][0] != '-') {
|
||||
gamma = (float)atof(argv[i+1]);
|
||||
gamma = atof(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
||||
else if (strcmp("mitchell", argv[i]) == 0) filter = new nv::MitchellFilter();
|
||||
else if (strcmp("lanczos", argv[i]) == 0) filter = new nv::LanczosFilter();
|
||||
else if (strcmp("kaiser", argv[i]) == 0) {
|
||||
filter = new nv::KaiserFilter(5);
|
||||
filter = new nv::KaiserFilter(3);
|
||||
((nv::KaiserFilter *)filter)->setParameters(4.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
@ -155,10 +155,7 @@ int main(int argc, char *argv[])
|
||||
nv::FloatImage fimage(&image);
|
||||
fimage.toLinear(0, 3, gamma);
|
||||
|
||||
int w = int(image.width() * scale);
|
||||
int h = int(image.height() * scale);
|
||||
|
||||
nv::AutoPtr<nv::FloatImage> fresult(fimage.downSample(*filter, w, h, nv::FloatImage::WrapMode_Mirror));
|
||||
nv::AutoPtr<nv::FloatImage> fresult(fimage.downSample(*filter, image.width() * scale, image.height() * scale, nv::FloatImage::WrapMode_Mirror));
|
||||
|
||||
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user