Skip to content

Commit

Permalink
4.4.3: careful use of memory areas
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed May 25, 2021
1 parent d409c9c commit 558f371
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 128 deletions.
23 changes: 10 additions & 13 deletions src/colors/grayscale-local/grayscale_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
#include "grayscale_local.h"
#include <QDebug>
#include <QGridLayout>
#include <QLabel>
#include <QDialogButtonBox>

#define PLUGIN_NAME "GrayScale (Local)"
#define PLUGIN_VERSION "1.0"
Expand Down Expand Up @@ -51,28 +48,28 @@ GrayScaleDialog:: GrayScaleDialog(QWidget *parent) : QDialog(parent)
this->setWindowTitle(PLUGIN_NAME);
this->resize(320, 184);

QGridLayout *gridLayout = new QGridLayout(this);
gridLayout = new QGridLayout(this);

QLabel *label = new QLabel("Radius :", this);
gridLayout->addWidget(label, 0, 0, 1, 1);
radiusLabel = new QLabel("Radius :", this);
gridLayout->addWidget(radiusLabel, 0, 0, 1, 1);

radiusSpin = new QSpinBox(this);
radiusSpin->setAlignment(Qt::AlignCenter);
radiusSpin->setRange(2, 1000);
radiusSpin->setValue(300);
gridLayout->addWidget(radiusSpin, 0, 1, 1, 1);

QLabel *label_2 = new QLabel("Samples :", this);
gridLayout->addWidget(label_2, 1, 0, 1, 1);
samplesLabel = new QLabel("Samples :", this);
gridLayout->addWidget(samplesLabel, 1, 0, 1, 1);

samplesSpin = new QSpinBox(this);
samplesSpin->setAlignment(Qt::AlignCenter);
samplesSpin->setRange(3, 17);
samplesSpin->setValue(4);
gridLayout->addWidget(samplesSpin, 1, 1, 1, 1);

QLabel *label_3 = new QLabel("Iterations :", this);
gridLayout->addWidget(label_3, 2, 0, 1, 1);
iterationsLabel = new QLabel("Iterations :", this);
gridLayout->addWidget(iterationsLabel, 2, 0, 1, 1);

iterationsSpin = new QSpinBox(this);
iterationsSpin->setAlignment(Qt::AlignCenter);
Expand All @@ -91,9 +88,9 @@ GrayScaleDialog:: GrayScaleDialog(QWidget *parent) : QDialog(parent)
samplesSpin->setToolTip(SAMPLES_DESC);
iterationsSpin->setToolTip(ITERATIONS_DESC);
enhanceShadowsBtn->setToolTip(ENHANCE_SHADOWS_DESC);
label->setToolTip(RADIUS_DESC);
label_2->setToolTip(SAMPLES_DESC);
label_3->setToolTip(ITERATIONS_DESC);
radiusLabel->setToolTip(RADIUS_DESC);
samplesLabel->setToolTip(SAMPLES_DESC);
iterationsLabel->setToolTip(ITERATIONS_DESC);

connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
Expand Down
10 changes: 7 additions & 3 deletions src/colors/grayscale-local/grayscale_local.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once
#include "plugin.h"
#include <QDialog>
#include <QGridLayout>
#include <QLabel>
#include <QSpinBox>
#include <QCheckBox>
#include <QDialogButtonBox>

class FilterPlugin : public QObject, Plugin
{
Expand All @@ -25,10 +28,11 @@ public slots:
class GrayScaleDialog : public QDialog
{
public:
QSpinBox *radiusSpin;
QSpinBox *samplesSpin;
QSpinBox *iterationsSpin;
QGridLayout *gridLayout;
QLabel *radiusLabel, *samplesLabel, *iterationsLabel;
QSpinBox *radiusSpin, *samplesSpin, *iterationsSpin;
QCheckBox *enhanceShadowsBtn;
QDialogButtonBox *buttonBox;

GrayScaleDialog(QWidget *parent);
};
1 change: 0 additions & 1 deletion src/colors/kuwahara/kuwahara.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

Q_EXPORT_PLUGIN2(kuwahara, FilterPlugin);


// takes 4 pixels and a floating point coordinate, returns bilinear interpolated pixel
QRgb interpolateBilinear(float x, float y, QRgb p00, QRgb p01, QRgb p10, QRgb p11)
{
Expand Down
16 changes: 5 additions & 11 deletions src/colors/quant/quant.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "quant.h"
#include <QLabel>
#include <QDialogButtonBox>
#include <QGridLayout>

#define PLUGIN_NAME "Quant"
#define PLUGIN_MENU "Filters/Color/Quant"
Expand All @@ -11,8 +8,6 @@
Q_EXPORT_PLUGIN2(quant, FilterPlugin);

// ********************** Quant Simple *********************
// clamp an integer in 0-255 range
#define Clamp(a) ( (a)&(~0xff) ? (uchar)((~a)>>31) : (a) )

void Quant(QImage &img, int red, int green, int blue)
{
Expand Down Expand Up @@ -52,34 +47,33 @@ QuantDialog:: QuantDialog(QWidget *parent) : QDialog(parent)
this->setWindowTitle(PLUGIN_NAME);
this->resize(320, 158);

QGridLayout *gridLayout = new QGridLayout(this);
gridLayout = new QGridLayout(this);

QLabel *redLabel = new QLabel("Red :", this);
redLabel = new QLabel("Red :", this);
gridLayout->addWidget(redLabel, 0, 0, 1, 1);
redSpin = new QSpinBox(this);
redSpin->setAlignment(Qt::AlignCenter);
redSpin->setRange(2, 256);
redSpin->setValue(8);
gridLayout->addWidget(redSpin, 0, 1, 1, 1);

QLabel *greenLabel = new QLabel("Green :", this);
greenLabel = new QLabel("Green :", this);
gridLayout->addWidget(greenLabel, 1, 0, 1, 1);
greenSpin = new QSpinBox(this);
greenSpin->setAlignment(Qt::AlignCenter);
greenSpin->setRange(2,256);
greenSpin->setValue(8);
gridLayout->addWidget(greenSpin, 1, 1, 1, 1);

QLabel *blueLabel = new QLabel("Blue :", this);
blueLabel = new QLabel("Blue :", this);
gridLayout->addWidget(blueLabel, 2, 0, 1, 1);
blueSpin = new QSpinBox(this);
blueSpin->setAlignment(Qt::AlignCenter);
blueSpin->setRange(2,256);
blueSpin->setValue(8);
gridLayout->addWidget(blueSpin, 2, 1, 1, 1);


QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
gridLayout->addWidget(buttonBox, 3, 0, 1, 2);

Expand Down
11 changes: 7 additions & 4 deletions src/colors/quant/quant.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once
#include "plugin.h"
#include <QDialog>
#include <QGridLayout>
#include <QLabel>
#include <QSpinBox>
#include <QCheckBox>
#include <QDialogButtonBox>

class FilterPlugin : public QObject, Plugin
{
Expand All @@ -25,9 +27,10 @@ public slots:
class QuantDialog : public QDialog
{
public:
QSpinBox *redSpin;
QSpinBox *greenSpin;
QSpinBox *blueSpin;
QGridLayout *gridLayout;
QLabel *redLabel, *greenLabel, *blueLabel;
QSpinBox *redSpin, *greenSpin, *blueSpin;
QDialogButtonBox *buttonBox;

QuantDialog(QWidget *parent);
};
1 change: 0 additions & 1 deletion src/colors/stretch-histogram/stretch_histogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ void stretchHistogram(QImage &img)
}

// ************** ---------- Plugin Class -----------************* //

QString FilterPlugin:: menuItem()
{
return QString(PLUGIN_MENU);
Expand Down
15 changes: 6 additions & 9 deletions src/colors/tone-mapping/tone_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
*/
#include "tone_mapping.h"
#include <QDebug>
#include <QGridLayout>
#include <QLabel>
#include <QDialogButtonBox>

#define PLUGIN_NAME "Tone Mapping"
#define PLUGIN_VERSION "1.0"
Expand Down Expand Up @@ -37,10 +34,10 @@ Mantiuk06Dialog:: Mantiuk06Dialog(QWidget *parent) : QDialog(parent)
this->setWindowTitle(PLUGIN_NAME);
this->resize(320, 158);

QGridLayout *gridLayout = new QGridLayout(this);
gridLayout = new QGridLayout(this);

QLabel *label = new QLabel("Contrast :", this);
gridLayout->addWidget(label, 0, 0, 1, 1);
contrastLabel = new QLabel("Contrast :", this);
gridLayout->addWidget(contrastLabel, 0, 0, 1, 1);

contrastSpin = new QDoubleSpinBox(this);
contrastSpin->setAlignment(Qt::AlignCenter);
Expand All @@ -49,8 +46,8 @@ Mantiuk06Dialog:: Mantiuk06Dialog(QWidget *parent) : QDialog(parent)
contrastSpin->setValue(0.1);
gridLayout->addWidget(contrastSpin, 0, 1, 1, 1);

QLabel *label_2 = new QLabel("Saturation :", this);
gridLayout->addWidget(label_2, 1, 0, 1, 1);
saturationLabel = new QLabel("Saturation :", this);
gridLayout->addWidget(saturationLabel, 1, 0, 1, 1);

saturationSpin = new QDoubleSpinBox(this);
saturationSpin->setAlignment(Qt::AlignCenter);
Expand All @@ -59,7 +56,7 @@ Mantiuk06Dialog:: Mantiuk06Dialog(QWidget *parent) : QDialog(parent)
saturationSpin->setValue(0.8);
gridLayout->addWidget(saturationSpin, 1, 1, 1, 1);

QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
gridLayout->addWidget(buttonBox, 2, 0, 1, 2);

Expand Down
11 changes: 7 additions & 4 deletions src/colors/tone-mapping/tone_mapping.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once
#include "plugin.h"
#include <QDialog>
#include <QGridLayout>
#include <QLabel>
#include <QDoubleSpinBox>

#include <QDialogButtonBox>

class FilterPlugin : public QObject, Plugin
{
Expand All @@ -21,12 +23,13 @@ public slots:
void sendNotification(QString title, QString message);
};


class Mantiuk06Dialog : public QDialog
{
public:
QDoubleSpinBox *contrastSpin;
QDoubleSpinBox *saturationSpin;
QGridLayout *gridLayout;
QLabel *contrastLabel, *saturationLabel;
QDoubleSpinBox *contrastSpin, *saturationSpin;
QDialogButtonBox *buttonBox;

Mantiuk06Dialog(QWidget *parent);
};
2 changes: 0 additions & 2 deletions src/colors/unalpha/unalpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Q_EXPORT_PLUGIN2(unalpha, FilterPlugin);

// ********************** Unalpha *********************
// clamp an integer in 0-255 range
#define Clamp(a) ( (a)&(~0xff) ? (uchar)((~a)>>31) : (a) )

void unalpha(QImage &img)
{
Expand Down
3 changes: 3 additions & 0 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <QImage>
#include <QWidget>

// clamp an integer in 0-255 range
#define Clamp(a) ((a)&(~0xff) ? (uchar)((~a)>>31) : (a))

typedef struct {
QImage image;
QString filename;
Expand Down
18 changes: 6 additions & 12 deletions src/threshold/bimodal-threshold/bimodal_thresh.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "bimodal_thresh.h"
#include <QLabel>
#include <QDialogButtonBox>
#include <QGridLayout>

#define PLUGIN_NAME "Bimodal Threshold"
#define PLUGIN_MENU "Filters/Threshold/Threshold Bimod"
Expand All @@ -11,9 +8,6 @@
Q_EXPORT_PLUGIN2(bimodal_thresh, FilterPlugin);

// ********************** Bimodal Threshold *********************
// clamp an integer in 0-255 range
#define Clamp(a) ( (a)&(~0xff) ? (uchar)((~a)>>31) : (a) )

int histogram_darkest(long long hist[])
{
for (int i=0; i<256; i++)
Expand Down Expand Up @@ -164,18 +158,18 @@ BimodThreshDialog:: BimodThreshDialog(QWidget *parent) : QDialog(parent)
this->setWindowTitle(PLUGIN_NAME);
this->resize(320, 158);

QGridLayout *gridLayout = new QGridLayout(this);
gridLayout = new QGridLayout(this);

QLabel *label = new QLabel("Colors Count :", this);
gridLayout->addWidget(label, 0, 0, 1, 1);
countLabel = new QLabel("Colors Count :", this);
gridLayout->addWidget(countLabel, 0, 0, 1, 1);

countSpin = new QSpinBox(this);
countSpin->setAlignment(Qt::AlignCenter);
countSpin->setRange(2, 255);
gridLayout->addWidget(countSpin, 0, 1, 1, 1);

QLabel *label_2 = new QLabel("Delta :", this);
gridLayout->addWidget(label_2, 1, 0, 1, 1);
deltaLabel = new QLabel("Delta :", this);
gridLayout->addWidget(deltaLabel, 1, 0, 1, 1);

deltaSpin = new QSpinBox(this);
deltaSpin->setAlignment(Qt::AlignCenter);
Expand All @@ -186,7 +180,7 @@ BimodThreshDialog:: BimodThreshDialog(QWidget *parent) : QDialog(parent)
medianBtn = new QCheckBox("Use Median", this);
gridLayout->addWidget(medianBtn, 2, 0, 1, 1);

QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
gridLayout->addWidget(buttonBox, 3, 0, 1, 2);

Expand Down
9 changes: 7 additions & 2 deletions src/threshold/bimodal-threshold/bimodal_thresh.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once
#include "plugin.h"
#include <QDialog>
#include <QGridLayout>
#include <QLabel>
#include <QSpinBox>
#include <QCheckBox>
#include <QDialogButtonBox>

class FilterPlugin : public QObject, Plugin
{
Expand All @@ -25,9 +28,11 @@ public slots:
class BimodThreshDialog : public QDialog
{
public:
QSpinBox *countSpin;
QSpinBox *deltaSpin;
QGridLayout *gridLayout;
QLabel *countLabel, *deltaLabel;
QSpinBox *countSpin, *deltaSpin;
QCheckBox *medianBtn;
QDialogButtonBox *buttonBox;

BimodThreshDialog(QWidget *parent);
};
Loading

0 comments on commit 558f371

Please sign in to comment.