提交 54424e00 编写于 作者: mahuifa's avatar mahuifa

新功能:Imagecomposition功能开发

上级 de0a895c
<RCC>
<qresource prefix="/">
<file>images/butterfly.png</file>
<file>images/checker.png</file>
</qresource>
</RCC>
......@@ -42,3 +42,6 @@ msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}
RESOURCES += \
Image.qrc
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
addOp(QPainter::CompositionMode_SourceOver, "SourceOver");
addOp(QPainter::CompositionMode_DestinationOver, "DestinationOver");
addOp(QPainter::CompositionMode_Clear, "Clear");
addOp(QPainter::CompositionMode_Source, "Source");
addOp(QPainter::CompositionMode_Destination, "Destination");
addOp(QPainter::CompositionMode_SourceIn, "SourceIn");
addOp(QPainter::CompositionMode_DestinationIn, "DestinationIn");
addOp(QPainter::CompositionMode_SourceOut, "SourceOut");
addOp(QPainter::CompositionMode_DestinationOut, "DestinationOut");
addOp(QPainter::CompositionMode_SourceAtop, "SourceAtop");
addOp(QPainter::CompositionMode_DestinationAtop, "DestinationAtop");
addOp(QPainter::CompositionMode_Xor, "Xor");
// svg 1.2混合模式
addOp(QPainter::CompositionMode_Plus, "Plus");
addOp(QPainter::CompositionMode_Multiply, "Multiply");
addOp(QPainter::CompositionMode_Screen, "Screen");
addOp(QPainter::CompositionMode_Overlay, "Overlay");
addOp(QPainter::CompositionMode_Darken, "Darken");
addOp(QPainter::CompositionMode_Lighten, "Lighten");
addOp(QPainter::CompositionMode_ColorDodge, "ColorDodge");
addOp(QPainter::CompositionMode_ColorBurn, "ColorBurn");
addOp(QPainter::CompositionMode_HardLight, "HardLight");
addOp(QPainter::CompositionMode_SoftLight, "SoftLight");
addOp(QPainter::CompositionMode_Difference, "Difference");
addOp(QPainter::CompositionMode_Exclusion, "Exclusion");
// ROPs
addOp(QPainter::RasterOp_SourceOrDestination, "SourceOrDestination");
addOp(QPainter::RasterOp_SourceAndDestination, "SourceAndDestination");
addOp(QPainter::RasterOp_SourceXorDestination, "SourceXorDestination");
addOp(QPainter::RasterOp_NotSourceAndNotDestination, "NotSourceAndNotDestination");
addOp(QPainter::RasterOp_NotSourceOrNotDestination, "NotSourceOrNotDestination");
addOp(QPainter::RasterOp_NotSourceXorDestination, "NotSourceXorDestination");
addOp(QPainter::RasterOp_NotSource, "NotSource");
addOp(QPainter::RasterOp_NotSourceAndDestination, "NotSourceAndDestination");
addOp(QPainter::RasterOp_SourceAndNotDestination, "SourceAndNotDestination");
addOp(QPainter::RasterOp_NotSourceOrDestination, "NotSourceOrDestination");
addOp(QPainter::RasterOp_SourceOrNotDestination, "SourceOrNotDestination");
addOp(QPainter::RasterOp_ClearDestination, "ClearDestination");
addOp(QPainter::RasterOp_SetDestination, "SetDestination");
addOp(QPainter::RasterOp_NotDestination, "NotDestination");
}
Widget::~Widget()
......@@ -13,3 +58,34 @@ Widget::~Widget()
delete ui;
}
void Widget::addOp(QPainter::CompositionMode mode, const QString &name)
{
ui->operatorComboBox->addItem(name, mode);
}
void Widget::loadImage(const QString &fileName, QImage &image, QToolButton *button)
{
if(!image.load(fileName)) // 加载图片
{
return;
}
image = image.scaled(ui->sourceButton->size(), Qt::KeepAspectRatio);
}
void Widget::on_sourceButton_clicked()
{
}
void Widget::on_destinationButton_clicked()
{
}
void Widget::on_operatorComboBox_currentIndexChanged(int index)
{
}
......@@ -2,6 +2,8 @@
#define WIDGET_H
#include <QWidget>
#include <QPainter>
#include <QToolButton>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
......@@ -15,7 +17,21 @@ public:
Widget(QWidget *parent = nullptr);
~Widget();
private slots:
void on_sourceButton_clicked();
void on_destinationButton_clicked();
void on_operatorComboBox_currentIndexChanged(int index);
private:
void addOp(QPainter::CompositionMode mode, const QString &name);
void loadImage(const QString &fileName, QImage& image, QToolButton *button);
private:
Ui::Widget *ui;
QImage sourceImage;
QImage destinationImage;
QImage resultImage;
};
#endif // WIDGET_H
......@@ -6,13 +6,77 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<width>1051</width>
<height>290</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QComboBox" name="operatorComboBox"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>31</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>=</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="resultLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="sourceButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="destinationButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册