summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregory <gregory.hainaut@gmail.com>2012-07-01 17:18:04 +0200
committergregory <gregory.hainaut@gmail.com>2012-07-01 17:18:04 +0200
commit8f0aa388f4463528f9278e7c58e4d029b45b850d (patch)
treef4e1a8bab800ab8ce59970d74584a9ef989feade
parent9cb30bec22c1c277a0bfb45628a0a59c36b1cfc5 (diff)
gui: new checkbox to visualize alpha channel of image
-rw-r--r--gui/imageviewer.cpp20
-rw-r--r--gui/ui/imageviewer.ui14
2 files changed, 28 insertions, 6 deletions
diff --git a/gui/imageviewer.cpp b/gui/imageviewer.cpp
index 7b1e425f..0e0657a3 100644
--- a/gui/imageviewer.cpp
+++ b/gui/imageviewer.cpp
@@ -19,6 +19,8 @@ ImageViewer::ImageViewer(QWidget *parent)
SLOT(slotUpdate()));
connect(opaqueCheckBox, SIGNAL(stateChanged(int)),
SLOT(slotUpdate()));
+ connect(alphaCheckBox, SIGNAL(stateChanged(int)),
+ SLOT(slotUpdate()));
QPixmap px(32, 32);
QPainter p(&px);
@@ -62,8 +64,9 @@ void ImageViewer::slotUpdate()
double upperValue = upperSpinBox->value();
bool opaque = opaqueCheckBox->isChecked();
+ bool alpha = alphaCheckBox->isChecked();
- if (lowerValue != 0.0 || upperValue != 1.0 || opaque) {
+ if (lowerValue != 0.0 || upperValue != 1.0 || opaque || alpha) {
/*
* Rescale the image.
*
@@ -95,11 +98,16 @@ void ImageViewer::slotUpdate()
int g = qGreen(pixel);
int b = qBlue(pixel);
int a = qAlpha(pixel);
- r = clamp(((r + offset) * scale) >> 8);
- g = clamp(((g + offset) * scale) >> 8);
- b = clamp(((b + offset) * scale) >> 8);
- a |= aMask;
- scanline[x] = qRgba(r, g, b, a);
+ if (alpha) {
+ a = clamp(((a + offset) * scale) >> 8);
+ scanline[x] = qRgba(a, a, a, 0xff);
+ } else {
+ r = clamp(((r + offset) * scale) >> 8);
+ g = clamp(((g + offset) * scale) >> 8);
+ b = clamp(((b + offset) * scale) >> 8);
+ a |= aMask;
+ scanline[x] = qRgba(r, g, b, a);
+ }
}
}
}
diff --git a/gui/ui/imageviewer.ui b/gui/ui/imageviewer.ui
index c6ab8460..bf63febb 100644
--- a/gui/ui/imageviewer.ui
+++ b/gui/ui/imageviewer.ui
@@ -91,6 +91,20 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="alphaCheckBox">
+ <property name="text">
+ <string>Alpha</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="depthCheckBox">
+ <property name="text">
+ <string>Depth</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>