修正大量demo
This commit is contained in:
@@ -86,14 +86,14 @@ ColorWidget::ColorWidget(QWidget *parent) : QWidget(parent)
|
|||||||
txtPoint = new QLineEdit(this);
|
txtPoint = new QLineEdit(this);
|
||||||
gridLayout->addWidget(txtPoint, 2, 2, 1, 1);
|
gridLayout->addWidget(txtPoint, 2, 2, 1, 1);
|
||||||
|
|
||||||
label->setText("当前颜色显示");
|
label->setText("当前颜色");
|
||||||
labWeb->setText("web值:");
|
labWeb->setText("web值:");
|
||||||
labRgb->setText("rgb值:");
|
labRgb->setText("rgb值:");
|
||||||
labPoint->setText("坐标值:");
|
labPoint->setText("坐标值:");
|
||||||
|
|
||||||
this->setLayout(gridLayout);
|
this->setLayout(gridLayout);
|
||||||
this->setWindowTitle("屏幕拾色器");
|
this->setWindowTitle("屏幕拾色器");
|
||||||
this->setFixedSize(270, 108);
|
this->setFixedSize(300, 108);
|
||||||
|
|
||||||
cp = QApplication::clipboard();
|
cp = QApplication::clipboard();
|
||||||
pressed = false;
|
pressed = false;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ColorWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
static ColorWidget *Instance();
|
static ColorWidget *Instance();
|
||||||
explicit ColorWidget(QWidget *parent = 0);
|
explicit ColorWidget(QWidget *parent = 0);
|
||||||
~ColorWidget();
|
~ColorWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|||||||
@@ -14,5 +14,10 @@ DESTDIR = $$PWD/../bin
|
|||||||
CONFIG += warn_off
|
CONFIG += warn_off
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
SOURCES += frmcolorwidget.cpp
|
||||||
SOURCES += colorwidget.cpp
|
SOURCES += colorwidget.cpp
|
||||||
|
|
||||||
HEADERS += colorwidget.h
|
HEADERS += colorwidget.h
|
||||||
|
HEADERS += frmcolorwidget.h
|
||||||
|
|
||||||
|
FORMS += frmcolorwidget.ui
|
||||||
|
|||||||
18
colorwidget/frmcolorwidget.cpp
Normal file
18
colorwidget/frmcolorwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "frmcolorwidget.h"
|
||||||
|
#include "ui_frmcolorwidget.h"
|
||||||
|
#include "colorwidget.h"
|
||||||
|
|
||||||
|
frmColorWidget::frmColorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmColorWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
frmColorWidget::~frmColorWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frmColorWidget::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
ColorWidget::Instance()->show();
|
||||||
|
}
|
||||||
25
colorwidget/frmcolorwidget.h
Normal file
25
colorwidget/frmcolorwidget.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef FRMCOLORWIDGET_H
|
||||||
|
#define FRMCOLORWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class frmColorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class frmColorWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit frmColorWidget(QWidget *parent = 0);
|
||||||
|
~frmColorWidget();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::frmColorWidget *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FRMCOLORWIDGET_H
|
||||||
32
colorwidget/frmcolorwidget.ui
Normal file
32
colorwidget/frmcolorwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>frmColorWidget</class>
|
||||||
|
<widget class="QWidget" name="frmColorWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>92</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>弹出</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
#include "colorwidget.h"
|
#include "frmcolorwidget.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QIcon>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -24,7 +23,9 @@ int main(int argc, char *argv[])
|
|||||||
QTextCodec::setCodecForLocale(codec);
|
QTextCodec::setCodecForLocale(codec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ColorWidget::Instance()->show();
|
frmColorWidget w;
|
||||||
|
w.setWindowTitle("屏幕拾色器");
|
||||||
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,6 @@ void FramelessWidget::setWidget(QWidget *widget)
|
|||||||
//绑定事件过滤器
|
//绑定事件过滤器
|
||||||
this->widget->installEventFilter(this);
|
this->widget->installEventFilter(this);
|
||||||
//设置悬停为真,必须设置这个,不然当父窗体里边还有子窗体全部遮挡了识别不到MouseMove,需要识别HoverMove
|
//设置悬停为真,必须设置这个,不然当父窗体里边还有子窗体全部遮挡了识别不到MouseMove,需要识别HoverMove
|
||||||
this->widget->setAttribute(Qt::WA_Hover, true);
|
this->widget->setAttribute(Qt::WA_Hover, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void frmFramelessWidget::closeEvent(QCloseEvent *)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void frmFramelessWidget::on_btnOpen_clicked()
|
void frmFramelessWidget::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
if (w == 0) {
|
if (w == 0) {
|
||||||
w = new QWidget;
|
w = new QWidget;
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
class FramelessWidget;
|
class FramelessWidget;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
class frmFramelessWidget;
|
||||||
class frmFramelessWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class frmFramelessWidget : public QWidget
|
class frmFramelessWidget : public QWidget
|
||||||
@@ -26,7 +25,7 @@ private:
|
|||||||
FramelessWidget *frameless;
|
FramelessWidget *frameless;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnOpen_clicked();
|
void on_pushButton_clicked();
|
||||||
void stateChanged1(int arg1);
|
void stateChanged1(int arg1);
|
||||||
void stateChanged2(int arg1);
|
void stateChanged2(int arg1);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,17 +13,17 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QPushButton" name="btnOpen">
|
<widget class="QPushButton" name="pushButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>181</width>
|
<width>92</width>
|
||||||
<height>23</height>
|
<height>28</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>弹窗无边框窗体</string>
|
<string>弹出</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
18
gifwidget/frmgifwidget.cpp
Normal file
18
gifwidget/frmgifwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "frmgifwidget.h"
|
||||||
|
#include "ui_frmgifwidget.h"
|
||||||
|
#include "gifwidget.h"
|
||||||
|
|
||||||
|
frmGifWidget::frmGifWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmGifWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
frmGifWidget::~frmGifWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frmGifWidget::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
GifWidget::Instance()->show();
|
||||||
|
}
|
||||||
25
gifwidget/frmgifwidget.h
Normal file
25
gifwidget/frmgifwidget.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef FRMGIFWIDGET_H
|
||||||
|
#define FRMGIFWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class frmGifWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class frmGifWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit frmGifWidget(QWidget *parent = 0);
|
||||||
|
~frmGifWidget();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::frmGifWidget *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FRMGIFWIDGET_H
|
||||||
32
gifwidget/frmgifwidget.ui
Normal file
32
gifwidget/frmgifwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>frmGifWidget</class>
|
||||||
|
<widget class="QWidget" name="frmGifWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>92</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>弹出</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
234
gifwidget/gif.h
234
gifwidget/gif.h
@@ -72,16 +72,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// max, min, and abs functions
|
// max, min, and abs functions
|
||||||
int GifIMax(int l, int r)
|
int GifIMax(int l, int r) {
|
||||||
{
|
|
||||||
return l > r ? l : r;
|
return l > r ? l : r;
|
||||||
}
|
}
|
||||||
int GifIMin(int l, int r)
|
int GifIMin(int l, int r) {
|
||||||
{
|
|
||||||
return l < r ? l : r;
|
return l < r ? l : r;
|
||||||
}
|
}
|
||||||
int GifIAbs(int i)
|
int GifIAbs(int i) {
|
||||||
{
|
|
||||||
return i < 0 ? -i : i;
|
return i < 0 ? -i : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +86,11 @@ public:
|
|||||||
// Takes as in/out parameters the current best color and its error -
|
// Takes as in/out parameters the current best color and its error -
|
||||||
// only changes them if it finds a better color in its subtree.
|
// only changes them if it finds a better color in its subtree.
|
||||||
// this is the major hotspot in the code at the moment.
|
// this is the major hotspot in the code at the moment.
|
||||||
void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int &bestInd, int &bestDiff, int treeRoot = 1)
|
void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int &bestInd, int &bestDiff, int treeRoot = 1) {
|
||||||
{
|
|
||||||
// base case, reached the bottom of the tree
|
// base case, reached the bottom of the tree
|
||||||
if(treeRoot > (1 << pPal->bitDepth) - 1) {
|
if (treeRoot > (1 << pPal->bitDepth) - 1) {
|
||||||
int ind = treeRoot - (1 << pPal->bitDepth);
|
int ind = treeRoot - (1 << pPal->bitDepth);
|
||||||
if(ind == kGifTransIndex) {
|
if (ind == kGifTransIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// check whether this color is better than the current winner
|
// check whether this color is better than the current winner
|
||||||
@@ -102,7 +98,7 @@ public:
|
|||||||
int g_err = g - ((int32_t)pPal->g[ind]);
|
int g_err = g - ((int32_t)pPal->g[ind]);
|
||||||
int b_err = b - ((int32_t)pPal->b[ind]);
|
int b_err = b - ((int32_t)pPal->b[ind]);
|
||||||
int diff = GifIAbs(r_err) + GifIAbs(g_err) + GifIAbs(b_err);
|
int diff = GifIAbs(r_err) + GifIAbs(g_err) + GifIAbs(b_err);
|
||||||
if(diff < bestDiff) {
|
if (diff < bestDiff) {
|
||||||
bestInd = ind;
|
bestInd = ind;
|
||||||
bestDiff = diff;
|
bestDiff = diff;
|
||||||
}
|
}
|
||||||
@@ -116,23 +112,22 @@ public:
|
|||||||
int splitComp = comps[pPal->treeSplitElt[treeRoot]];
|
int splitComp = comps[pPal->treeSplitElt[treeRoot]];
|
||||||
|
|
||||||
int splitPos = pPal->treeSplit[treeRoot];
|
int splitPos = pPal->treeSplit[treeRoot];
|
||||||
if(splitPos > splitComp) {
|
if (splitPos > splitComp) {
|
||||||
// check the left subtree
|
// check the left subtree
|
||||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2);
|
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2);
|
||||||
if( bestDiff > splitPos - splitComp ) {
|
if (bestDiff > splitPos - splitComp) {
|
||||||
// cannot prove there's not a better value in the right subtree, check that too
|
// cannot prove there's not a better value in the right subtree, check that too
|
||||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2 + 1);
|
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2 + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2 + 1);
|
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2 + 1);
|
||||||
if( bestDiff > splitComp - splitPos ) {
|
if (bestDiff > splitComp - splitPos) {
|
||||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2);
|
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifSwapPixels(uint8_t *image, int pixA, int pixB)
|
void GifSwapPixels(uint8_t *image, int pixA, int pixB) {
|
||||||
{
|
|
||||||
uint8_t rA = image[pixA * 4];
|
uint8_t rA = image[pixA * 4];
|
||||||
uint8_t gA = image[pixA * 4 + 1];
|
uint8_t gA = image[pixA * 4 + 1];
|
||||||
uint8_t bA = image[pixA * 4 + 2];
|
uint8_t bA = image[pixA * 4 + 2];
|
||||||
@@ -155,19 +150,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// just the partition operation from quicksort
|
// just the partition operation from quicksort
|
||||||
int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex)
|
int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex) {
|
||||||
{
|
|
||||||
const int pivotValue = image[(pivotIndex) * 4 + elt];
|
const int pivotValue = image[(pivotIndex) * 4 + elt];
|
||||||
GifSwapPixels(image, pivotIndex, right - 1);
|
GifSwapPixels(image, pivotIndex, right - 1);
|
||||||
int storeIndex = left;
|
int storeIndex = left;
|
||||||
bool split = 0;
|
bool split = 0;
|
||||||
for(int ii = left; ii < right - 1; ++ii) {
|
for (int ii = left; ii < right - 1; ++ii) {
|
||||||
int arrayVal = image[ii * 4 + elt];
|
int arrayVal = image[ii * 4 + elt];
|
||||||
if( arrayVal < pivotValue ) {
|
if (arrayVal < pivotValue) {
|
||||||
GifSwapPixels(image, ii, storeIndex);
|
GifSwapPixels(image, ii, storeIndex);
|
||||||
++storeIndex;
|
++storeIndex;
|
||||||
} else if( arrayVal == pivotValue ) {
|
} else if (arrayVal == pivotValue) {
|
||||||
if(split) {
|
if (split) {
|
||||||
GifSwapPixels(image, ii, storeIndex);
|
GifSwapPixels(image, ii, storeIndex);
|
||||||
++storeIndex;
|
++storeIndex;
|
||||||
}
|
}
|
||||||
@@ -179,16 +173,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform an incomplete sort, finding all elements above and below the desired median
|
// Perform an incomplete sort, finding all elements above and below the desired median
|
||||||
void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter)
|
void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter) {
|
||||||
{
|
|
||||||
if (left < right - 1) {
|
if (left < right - 1) {
|
||||||
int pivotIndex = left + (right - left) / 2;
|
int pivotIndex = left + (right - left) / 2;
|
||||||
pivotIndex = GifPartition(image, left, right, com, pivotIndex);
|
pivotIndex = GifPartition(image, left, right, com, pivotIndex);
|
||||||
// Only "sort" the section of the array that contains the median
|
// Only "sort" the section of the array that contains the median
|
||||||
if(pivotIndex > neededCenter) {
|
if (pivotIndex > neededCenter) {
|
||||||
GifPartitionByMedian(image, left, pivotIndex, com, neededCenter);
|
GifPartitionByMedian(image, left, pivotIndex, com, neededCenter);
|
||||||
}
|
}
|
||||||
if(pivotIndex < neededCenter) {
|
if (pivotIndex < neededCenter) {
|
||||||
GifPartitionByMedian(image, pivotIndex + 1, right, com, neededCenter);
|
GifPartitionByMedian(image, pivotIndex + 1, right, com, neededCenter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,8 +192,7 @@ public:
|
|||||||
int numPixels, int firstElt,
|
int numPixels, int firstElt,
|
||||||
int lastElt, int splitElt,
|
int lastElt, int splitElt,
|
||||||
int splitDist, int treeNode,
|
int splitDist, int treeNode,
|
||||||
bool buildForDither, GifPalette *pal)
|
bool buildForDither, GifPalette *pal) {
|
||||||
{
|
|
||||||
if (lastElt <= firstElt || numPixels == 0) {
|
if (lastElt <= firstElt || numPixels == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -210,10 +202,10 @@ public:
|
|||||||
// Dithering needs at least one color as dark as anything
|
// Dithering needs at least one color as dark as anything
|
||||||
// in the image and at least one brightest color -
|
// in the image and at least one brightest color -
|
||||||
// otherwise it builds up error and produces strange artifacts
|
// otherwise it builds up error and produces strange artifacts
|
||||||
if( firstElt == 1 ) {
|
if (firstElt == 1) {
|
||||||
// special case: the darkest color in the image
|
// special case: the darkest color in the image
|
||||||
uint32_t r = 255, g = 255, b = 255;
|
uint32_t r = 255, g = 255, b = 255;
|
||||||
for(int ii = 0; ii < numPixels; ++ii) {
|
for (int ii = 0; ii < numPixels; ++ii) {
|
||||||
r = (uint32_t)GifIMin((int32_t)r, image[ii * 4 + 0]);
|
r = (uint32_t)GifIMin((int32_t)r, image[ii * 4 + 0]);
|
||||||
g = (uint32_t)GifIMin((int32_t)g, image[ii * 4 + 1]);
|
g = (uint32_t)GifIMin((int32_t)g, image[ii * 4 + 1]);
|
||||||
b = (uint32_t)GifIMin((int32_t)b, image[ii * 4 + 2]);
|
b = (uint32_t)GifIMin((int32_t)b, image[ii * 4 + 2]);
|
||||||
@@ -224,10 +216,10 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( firstElt == (1 << pal->bitDepth) - 1 ) {
|
if (firstElt == (1 << pal->bitDepth) - 1) {
|
||||||
// special case: the lightest color in the image
|
// special case: the lightest color in the image
|
||||||
uint32_t r = 0, g = 0, b = 0;
|
uint32_t r = 0, g = 0, b = 0;
|
||||||
for(int ii = 0; ii < numPixels; ++ii) {
|
for (int ii = 0; ii < numPixels; ++ii) {
|
||||||
r = (uint32_t)GifIMax((int32_t)r, image[ii * 4 + 0]);
|
r = (uint32_t)GifIMax((int32_t)r, image[ii * 4 + 0]);
|
||||||
g = (uint32_t)GifIMax((int32_t)g, image[ii * 4 + 1]);
|
g = (uint32_t)GifIMax((int32_t)g, image[ii * 4 + 1]);
|
||||||
b = (uint32_t)GifIMax((int32_t)b, image[ii * 4 + 2]);
|
b = (uint32_t)GifIMax((int32_t)b, image[ii * 4 + 2]);
|
||||||
@@ -263,29 +255,29 @@ public:
|
|||||||
int minR = 255, maxR = 0;
|
int minR = 255, maxR = 0;
|
||||||
int minG = 255, maxG = 0;
|
int minG = 255, maxG = 0;
|
||||||
int minB = 255, maxB = 0;
|
int minB = 255, maxB = 0;
|
||||||
for(int ii = 0; ii < numPixels; ++ii) {
|
for (int ii = 0; ii < numPixels; ++ii) {
|
||||||
int r = image[ii * 4 + 0];
|
int r = image[ii * 4 + 0];
|
||||||
int g = image[ii * 4 + 1];
|
int g = image[ii * 4 + 1];
|
||||||
int b = image[ii * 4 + 2];
|
int b = image[ii * 4 + 2];
|
||||||
|
|
||||||
if(r > maxR) {
|
if (r > maxR) {
|
||||||
maxR = r;
|
maxR = r;
|
||||||
}
|
}
|
||||||
if(r < minR) {
|
if (r < minR) {
|
||||||
minR = r;
|
minR = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g > maxG) {
|
if (g > maxG) {
|
||||||
maxG = g;
|
maxG = g;
|
||||||
}
|
}
|
||||||
if(g < minG) {
|
if (g < minG) {
|
||||||
minG = g;
|
minG = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b > maxB) {
|
if (b > maxB) {
|
||||||
maxB = b;
|
maxB = b;
|
||||||
}
|
}
|
||||||
if(b < minB) {
|
if (b < minB) {
|
||||||
minB = b;
|
minB = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,14 +310,13 @@ public:
|
|||||||
// moves them to the fromt of th buffer.
|
// moves them to the fromt of th buffer.
|
||||||
// This allows us to build a palette optimized for the colors of the
|
// This allows us to build a palette optimized for the colors of the
|
||||||
// changed pixels only.
|
// changed pixels only.
|
||||||
int GifPickChangedPixels( const uint8_t *lastFrame, uint8_t *frame, int numPixels )
|
int GifPickChangedPixels(const uint8_t *lastFrame, uint8_t *frame, int numPixels) {
|
||||||
{
|
|
||||||
int numChanged = 0;
|
int numChanged = 0;
|
||||||
uint8_t *writeIter = frame;
|
uint8_t *writeIter = frame;
|
||||||
for (int ii = 0; ii < numPixels; ++ii) {
|
for (int ii = 0; ii < numPixels; ++ii) {
|
||||||
if(lastFrame[0] != frame[0] ||
|
if (lastFrame[0] != frame[0] ||
|
||||||
lastFrame[1] != frame[1] ||
|
lastFrame[1] != frame[1] ||
|
||||||
lastFrame[2] != frame[2]) {
|
lastFrame[2] != frame[2]) {
|
||||||
writeIter[0] = frame[0];
|
writeIter[0] = frame[0];
|
||||||
writeIter[1] = frame[1];
|
writeIter[1] = frame[1];
|
||||||
writeIter[2] = frame[2];
|
writeIter[2] = frame[2];
|
||||||
@@ -340,12 +331,11 @@ public:
|
|||||||
|
|
||||||
// Creates a palette by placing all the image pixels in a k-d tree and then averaging the blocks at the bottom.
|
// Creates a palette by placing all the image pixels in a k-d tree and then averaging the blocks at the bottom.
|
||||||
// This is known as the "modified median split" technique
|
// This is known as the "modified median split" technique
|
||||||
void GifMakePalette( const uint8_t *lastFrame,
|
void GifMakePalette(const uint8_t *lastFrame,
|
||||||
const uint8_t *nextFrame,
|
const uint8_t *nextFrame,
|
||||||
uint32_t width, uint32_t height,
|
uint32_t width, uint32_t height,
|
||||||
int bitDepth, bool buildForDither,
|
int bitDepth, bool buildForDither,
|
||||||
GifPalette *pPal )
|
GifPalette *pPal) {
|
||||||
{
|
|
||||||
pPal->bitDepth = bitDepth;
|
pPal->bitDepth = bitDepth;
|
||||||
|
|
||||||
// SplitPalette is destructive (it sorts the pixels by color) so
|
// SplitPalette is destructive (it sorts the pixels by color) so
|
||||||
@@ -355,7 +345,7 @@ public:
|
|||||||
memcpy(destroyableImage, nextFrame, imageSize);
|
memcpy(destroyableImage, nextFrame, imageSize);
|
||||||
|
|
||||||
int numPixels = (int)(width * height);
|
int numPixels = (int)(width * height);
|
||||||
if(lastFrame) {
|
if (lastFrame) {
|
||||||
numPixels = GifPickChangedPixels(lastFrame, destroyableImage, numPixels);
|
numPixels = GifPickChangedPixels(lastFrame, destroyableImage, numPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,24 +365,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements Floyd-Steinberg dithering, writes palette value to alpha
|
// Implements Floyd-Steinberg dithering, writes palette value to alpha
|
||||||
void GifDitherImage( const uint8_t *lastFrame, const uint8_t *nextFrame,
|
void GifDitherImage(const uint8_t *lastFrame, const uint8_t *nextFrame,
|
||||||
uint8_t *outFrame, uint32_t width,
|
uint8_t *outFrame, uint32_t width,
|
||||||
uint32_t height, GifPalette *pPal )
|
uint32_t height, GifPalette *pPal) {
|
||||||
{
|
|
||||||
int numPixels = (int)(width * height);
|
int numPixels = (int)(width * height);
|
||||||
|
|
||||||
// quantPixels initially holds color*256 for all pixels
|
// quantPixels initially holds color*256 for all pixels
|
||||||
// The extra 8 bits of precision allow for sub-single-color error values
|
// The extra 8 bits of precision allow for sub-single-color error values
|
||||||
// to be propagated
|
// to be propagated
|
||||||
int32_t *quantPixels = (int32_t *)GIF_TEMP_MALLOC(sizeof(int32_t) * (size_t)numPixels * 4);
|
int32_t *quantPixels = (int32_t *)GIF_TEMP_MALLOC(sizeof(int32_t) * (size_t)numPixels * 4);
|
||||||
for( int ii = 0; ii < numPixels * 4; ++ii ) {
|
for (int ii = 0; ii < numPixels * 4; ++ii) {
|
||||||
uint8_t pix = nextFrame[ii];
|
uint8_t pix = nextFrame[ii];
|
||||||
int32_t pix16 = int32_t(pix) * 256;
|
int32_t pix16 = int32_t(pix) * 256;
|
||||||
quantPixels[ii] = pix16;
|
quantPixels[ii] = pix16;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( uint32_t yy = 0; yy < height; ++yy ) {
|
for (uint32_t yy = 0; yy < height; ++yy) {
|
||||||
for( uint32_t xx = 0; xx < width; ++xx ) {
|
for (uint32_t xx = 0; xx < width; ++xx) {
|
||||||
int32_t *nextPix = quantPixels + 4 * (yy * width + xx);
|
int32_t *nextPix = quantPixels + 4 * (yy * width + xx);
|
||||||
const uint8_t *lastPix = lastFrame ? lastFrame + 4 * (yy * width + xx) : NULL;
|
const uint8_t *lastPix = lastFrame ? lastFrame + 4 * (yy * width + xx) : NULL;
|
||||||
// Compute the colors we want (rounding to nearest)
|
// Compute the colors we want (rounding to nearest)
|
||||||
@@ -401,10 +390,10 @@ public:
|
|||||||
int32_t bb = (nextPix[2] + 127) / 256;
|
int32_t bb = (nextPix[2] + 127) / 256;
|
||||||
// if it happens that we want the color from last frame, then just write out
|
// if it happens that we want the color from last frame, then just write out
|
||||||
// a transparent pixel
|
// a transparent pixel
|
||||||
if( lastFrame &&
|
if (lastFrame &&
|
||||||
lastPix[0] == rr &&
|
lastPix[0] == rr &&
|
||||||
lastPix[1] == gg &&
|
lastPix[1] == gg &&
|
||||||
lastPix[2] == bb ) {
|
lastPix[2] == bb) {
|
||||||
nextPix[0] = rr;
|
nextPix[0] = rr;
|
||||||
nextPix[1] = gg;
|
nextPix[1] = gg;
|
||||||
nextPix[2] = bb;
|
nextPix[2] = bb;
|
||||||
@@ -433,37 +422,37 @@ public:
|
|||||||
int quantloc_5 = (int)(yy * width + width + xx);
|
int quantloc_5 = (int)(yy * width + width + xx);
|
||||||
int quantloc_1 = (int)(yy * width + width + xx + 1);
|
int quantloc_1 = (int)(yy * width + width + xx + 1);
|
||||||
|
|
||||||
if(quantloc_7 < numPixels) {
|
if (quantloc_7 < numPixels) {
|
||||||
int32_t *pix7 = quantPixels + 4 * quantloc_7;
|
int32_t *pix7 = quantPixels + 4 * quantloc_7;
|
||||||
pix7[0] += GifIMax( -pix7[0], r_err * 7 / 16 );
|
pix7[0] += GifIMax(-pix7[0], r_err * 7 / 16);
|
||||||
pix7[1] += GifIMax( -pix7[1], g_err * 7 / 16 );
|
pix7[1] += GifIMax(-pix7[1], g_err * 7 / 16);
|
||||||
pix7[2] += GifIMax( -pix7[2], b_err * 7 / 16 );
|
pix7[2] += GifIMax(-pix7[2], b_err * 7 / 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(quantloc_3 < numPixels) {
|
if (quantloc_3 < numPixels) {
|
||||||
int32_t *pix3 = quantPixels + 4 * quantloc_3;
|
int32_t *pix3 = quantPixels + 4 * quantloc_3;
|
||||||
pix3[0] += GifIMax( -pix3[0], r_err * 3 / 16 );
|
pix3[0] += GifIMax(-pix3[0], r_err * 3 / 16);
|
||||||
pix3[1] += GifIMax( -pix3[1], g_err * 3 / 16 );
|
pix3[1] += GifIMax(-pix3[1], g_err * 3 / 16);
|
||||||
pix3[2] += GifIMax( -pix3[2], b_err * 3 / 16 );
|
pix3[2] += GifIMax(-pix3[2], b_err * 3 / 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(quantloc_5 < numPixels) {
|
if (quantloc_5 < numPixels) {
|
||||||
int32_t *pix5 = quantPixels + 4 * quantloc_5;
|
int32_t *pix5 = quantPixels + 4 * quantloc_5;
|
||||||
pix5[0] += GifIMax( -pix5[0], r_err * 5 / 16 );
|
pix5[0] += GifIMax(-pix5[0], r_err * 5 / 16);
|
||||||
pix5[1] += GifIMax( -pix5[1], g_err * 5 / 16 );
|
pix5[1] += GifIMax(-pix5[1], g_err * 5 / 16);
|
||||||
pix5[2] += GifIMax( -pix5[2], b_err * 5 / 16 );
|
pix5[2] += GifIMax(-pix5[2], b_err * 5 / 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(quantloc_1 < numPixels) {
|
if (quantloc_1 < numPixels) {
|
||||||
int32_t *pix1 = quantPixels + 4 * quantloc_1;
|
int32_t *pix1 = quantPixels + 4 * quantloc_1;
|
||||||
pix1[0] += GifIMax( -pix1[0], r_err / 16 );
|
pix1[0] += GifIMax(-pix1[0], r_err / 16);
|
||||||
pix1[1] += GifIMax( -pix1[1], g_err / 16 );
|
pix1[1] += GifIMax(-pix1[1], g_err / 16);
|
||||||
pix1[2] += GifIMax( -pix1[2], b_err / 16 );
|
pix1[2] += GifIMax(-pix1[2], b_err / 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Copy the palettized result to the output buffer
|
// Copy the palettized result to the output buffer
|
||||||
for( int ii = 0; ii < numPixels * 4; ++ii ) {
|
for (int ii = 0; ii < numPixels * 4; ++ii) {
|
||||||
outFrame[ii] = (uint8_t)quantPixels[ii];
|
outFrame[ii] = (uint8_t)quantPixels[ii];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,18 +460,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Picks palette colors for the image using simple thresholding, no dithering
|
// Picks palette colors for the image using simple thresholding, no dithering
|
||||||
void GifThresholdImage( const uint8_t *lastFrame, const uint8_t *nextFrame,
|
void GifThresholdImage(const uint8_t *lastFrame, const uint8_t *nextFrame,
|
||||||
uint8_t *outFrame, uint32_t width, uint32_t height,
|
uint8_t *outFrame, uint32_t width, uint32_t height,
|
||||||
GifPalette *pPal )
|
GifPalette *pPal) {
|
||||||
{
|
|
||||||
uint32_t numPixels = width * height;
|
uint32_t numPixels = width * height;
|
||||||
for( uint32_t ii = 0; ii < numPixels; ++ii ) {
|
for (uint32_t ii = 0; ii < numPixels; ++ii) {
|
||||||
// if a previous color is available, and it matches the current color,
|
// if a previous color is available, and it matches the current color,
|
||||||
// set the pixel to transparent
|
// set the pixel to transparent
|
||||||
if(lastFrame &&
|
if (lastFrame &&
|
||||||
lastFrame[0] == nextFrame[0] &&
|
lastFrame[0] == nextFrame[0] &&
|
||||||
lastFrame[1] == nextFrame[1] &&
|
lastFrame[1] == nextFrame[1] &&
|
||||||
lastFrame[2] == nextFrame[2]) {
|
lastFrame[2] == nextFrame[2]) {
|
||||||
outFrame[0] = lastFrame[0];
|
outFrame[0] = lastFrame[0];
|
||||||
outFrame[1] = lastFrame[1];
|
outFrame[1] = lastFrame[1];
|
||||||
outFrame[2] = lastFrame[2];
|
outFrame[2] = lastFrame[2];
|
||||||
@@ -499,7 +487,7 @@ public:
|
|||||||
outFrame[2] = pPal->b[bestInd];
|
outFrame[2] = pPal->b[bestInd];
|
||||||
outFrame[3] = (uint8_t)bestInd;
|
outFrame[3] = (uint8_t)bestInd;
|
||||||
}
|
}
|
||||||
if(lastFrame) {
|
if (lastFrame) {
|
||||||
lastFrame += 4;
|
lastFrame += 4;
|
||||||
}
|
}
|
||||||
outFrame += 4;
|
outFrame += 4;
|
||||||
@@ -518,14 +506,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// insert a single bit
|
// insert a single bit
|
||||||
void GifWriteBit( GifBitStatus &stat, uint32_t bit )
|
void GifWriteBit(GifBitStatus &stat, uint32_t bit) {
|
||||||
{
|
|
||||||
bit = bit & 1;
|
bit = bit & 1;
|
||||||
bit = bit << stat.bitIndex;
|
bit = bit << stat.bitIndex;
|
||||||
stat.byte |= bit;
|
stat.byte |= bit;
|
||||||
|
|
||||||
++stat.bitIndex;
|
++stat.bitIndex;
|
||||||
if( stat.bitIndex > 7 ) {
|
if (stat.bitIndex > 7) {
|
||||||
// move the newly-finished byte to the chunk buffer
|
// move the newly-finished byte to the chunk buffer
|
||||||
stat.chunk[stat.chunkIndex++] = stat.byte;
|
stat.chunk[stat.chunkIndex++] = stat.byte;
|
||||||
// and start a new byte
|
// and start a new byte
|
||||||
@@ -535,8 +522,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write all bytes so far to the file
|
// write all bytes so far to the file
|
||||||
void GifWriteChunk( FILE *f, GifBitStatus &stat )
|
void GifWriteChunk(FILE *f, GifBitStatus &stat) {
|
||||||
{
|
|
||||||
fputc((int)stat.chunkIndex, f);
|
fputc((int)stat.chunkIndex, f);
|
||||||
fwrite(stat.chunk, 1, stat.chunkIndex, f);
|
fwrite(stat.chunk, 1, stat.chunkIndex, f);
|
||||||
|
|
||||||
@@ -545,12 +531,11 @@ public:
|
|||||||
stat.chunkIndex = 0;
|
stat.chunkIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifWriteCode( FILE *f, GifBitStatus &stat, uint32_t code, uint32_t length )
|
void GifWriteCode(FILE *f, GifBitStatus &stat, uint32_t code, uint32_t length) {
|
||||||
{
|
for (uint32_t ii = 0; ii < length; ++ii) {
|
||||||
for( uint32_t ii = 0; ii < length; ++ii ) {
|
|
||||||
GifWriteBit(stat, code);
|
GifWriteBit(stat, code);
|
||||||
code = code >> 1;
|
code = code >> 1;
|
||||||
if( stat.chunkIndex == 255 ) {
|
if (stat.chunkIndex == 255) {
|
||||||
GifWriteChunk(f, stat);
|
GifWriteChunk(f, stat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,12 +548,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// write a 256-color (8-bit) image palette to the file
|
// write a 256-color (8-bit) image palette to the file
|
||||||
void GifWritePalette( const GifPalette *pPal, FILE *f )
|
void GifWritePalette(const GifPalette *pPal, FILE *f) {
|
||||||
{
|
|
||||||
fputc(0, f); // first color: transparency
|
fputc(0, f); // first color: transparency
|
||||||
fputc(0, f);
|
fputc(0, f);
|
||||||
fputc(0, f);
|
fputc(0, f);
|
||||||
for(int ii = 1; ii < (1 << pPal->bitDepth); ++ii) {
|
for (int ii = 1; ii < (1 << pPal->bitDepth); ++ii) {
|
||||||
uint32_t r = pPal->r[ii];
|
uint32_t r = pPal->r[ii];
|
||||||
uint32_t g = pPal->g[ii];
|
uint32_t g = pPal->g[ii];
|
||||||
uint32_t b = pPal->b[ii];
|
uint32_t b = pPal->b[ii];
|
||||||
@@ -582,8 +566,7 @@ public:
|
|||||||
void GifWriteLzwImage(FILE *f, uint8_t *image, uint32_t left,
|
void GifWriteLzwImage(FILE *f, uint8_t *image, uint32_t left,
|
||||||
uint32_t top, uint32_t width,
|
uint32_t top, uint32_t width,
|
||||||
uint32_t height, uint32_t delay,
|
uint32_t height, uint32_t delay,
|
||||||
GifPalette *pPal)
|
GifPalette *pPal) {
|
||||||
{
|
|
||||||
// graphics control extension
|
// graphics control extension
|
||||||
fputc(0x21, f);
|
fputc(0x21, f);
|
||||||
fputc(0xf9, f);
|
fputc(0xf9, f);
|
||||||
@@ -631,16 +614,16 @@ public:
|
|||||||
|
|
||||||
GifWriteCode(f, stat, clearCode, codeSize); // start with a fresh LZW dictionary
|
GifWriteCode(f, stat, clearCode, codeSize); // start with a fresh LZW dictionary
|
||||||
|
|
||||||
for(uint32_t yy = 0; yy < height; ++yy) {
|
for (uint32_t yy = 0; yy < height; ++yy) {
|
||||||
for(uint32_t xx = 0; xx < width; ++xx) {
|
for (uint32_t xx = 0; xx < width; ++xx) {
|
||||||
uint8_t nextValue = image[(yy * width + xx) * 4 + 3];
|
uint8_t nextValue = image[(yy * width + xx) * 4 + 3];
|
||||||
// "loser mode" - no compression, every single code is followed immediately by a clear
|
// "loser mode" - no compression, every single code is followed immediately by a clear
|
||||||
//WriteCode( f, stat, nextValue, codeSize );
|
//WriteCode( f, stat, nextValue, codeSize );
|
||||||
//WriteCode( f, stat, 256, codeSize );
|
//WriteCode( f, stat, 256, codeSize );
|
||||||
if( curCode < 0 ) {
|
if (curCode < 0) {
|
||||||
// first value in a new run
|
// first value in a new run
|
||||||
curCode = nextValue;
|
curCode = nextValue;
|
||||||
} else if( codetree[curCode].m_next[nextValue] ) {
|
} else if (codetree[curCode].m_next[nextValue]) {
|
||||||
// current run already in the dictionary
|
// current run already in the dictionary
|
||||||
curCode = codetree[curCode].m_next[nextValue];
|
curCode = codetree[curCode].m_next[nextValue];
|
||||||
} else {
|
} else {
|
||||||
@@ -648,12 +631,12 @@ public:
|
|||||||
GifWriteCode(f, stat, (uint32_t)curCode, codeSize);
|
GifWriteCode(f, stat, (uint32_t)curCode, codeSize);
|
||||||
// insert the new run into the dictionary
|
// insert the new run into the dictionary
|
||||||
codetree[curCode].m_next[nextValue] = (uint16_t)++maxCode;
|
codetree[curCode].m_next[nextValue] = (uint16_t)++maxCode;
|
||||||
if( maxCode >= (1ul << codeSize) ) {
|
if (maxCode >= (1ul << codeSize)) {
|
||||||
// dictionary entry count has broken a size barrier,
|
// dictionary entry count has broken a size barrier,
|
||||||
// we need more bits for codes
|
// we need more bits for codes
|
||||||
codeSize++;
|
codeSize++;
|
||||||
}
|
}
|
||||||
if( maxCode == 4095 ) {
|
if (maxCode == 4095) {
|
||||||
// the dictionary is full, clear it out and begin anew
|
// the dictionary is full, clear it out and begin anew
|
||||||
GifWriteCode(f, stat, clearCode, codeSize); // clear tree
|
GifWriteCode(f, stat, clearCode, codeSize); // clear tree
|
||||||
|
|
||||||
@@ -670,10 +653,10 @@ public:
|
|||||||
GifWriteCode(f, stat, clearCode, codeSize);
|
GifWriteCode(f, stat, clearCode, codeSize);
|
||||||
GifWriteCode(f, stat, clearCode + 1, (uint32_t)minCodeSize + 1);
|
GifWriteCode(f, stat, clearCode + 1, (uint32_t)minCodeSize + 1);
|
||||||
// write out the last partial chunk
|
// write out the last partial chunk
|
||||||
while( stat.bitIndex ) {
|
while (stat.bitIndex) {
|
||||||
GifWriteBit(stat, 0);
|
GifWriteBit(stat, 0);
|
||||||
}
|
}
|
||||||
if( stat.chunkIndex ) {
|
if (stat.chunkIndex) {
|
||||||
GifWriteChunk(f, stat);
|
GifWriteChunk(f, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,11 +674,10 @@ public:
|
|||||||
// Creates a gif file.
|
// Creates a gif file.
|
||||||
// The input GIFWriter is assumed to be uninitialized.
|
// The input GIFWriter is assumed to be uninitialized.
|
||||||
// The delay value is the time between frames in hundredths of a second - note that not all viewers pay much attention to this value.
|
// The delay value is the time between frames in hundredths of a second - note that not all viewers pay much attention to this value.
|
||||||
bool GifBegin( GifWriter *writer, const char *filename,
|
bool GifBegin(GifWriter *writer, const char *filename,
|
||||||
uint32_t width, uint32_t height,
|
uint32_t width, uint32_t height,
|
||||||
uint32_t delay, int32_t bitDepth = 8,
|
uint32_t delay, int32_t bitDepth = 8,
|
||||||
bool dither = false )
|
bool dither = false) {
|
||||||
{
|
|
||||||
(void)bitDepth;
|
(void)bitDepth;
|
||||||
(void)dither; // Mute "Unused argument" warnings
|
(void)dither; // Mute "Unused argument" warnings
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
@@ -704,7 +686,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
writer->f = fopen(filename, "wb");
|
writer->f = fopen(filename, "wb");
|
||||||
#endif
|
#endif
|
||||||
if(!writer->f) {
|
if (!writer->f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,7 +716,7 @@ public:
|
|||||||
fputc(0, writer->f);
|
fputc(0, writer->f);
|
||||||
fputc(0, writer->f);
|
fputc(0, writer->f);
|
||||||
|
|
||||||
if( delay != 0 ) {
|
if (delay != 0) {
|
||||||
// animation header
|
// animation header
|
||||||
fputc(0x21, writer->f); // extension
|
fputc(0x21, writer->f); // extension
|
||||||
fputc(0xff, writer->f); // application specific
|
fputc(0xff, writer->f); // application specific
|
||||||
@@ -755,11 +737,10 @@ public:
|
|||||||
// The GIFWriter should have been created by GIFBegin.
|
// The GIFWriter should have been created by GIFBegin.
|
||||||
// AFAIK, it is legal to use different bit depths for different frames of an image -
|
// AFAIK, it is legal to use different bit depths for different frames of an image -
|
||||||
// this may be handy to save bits in animations that don't change much.
|
// this may be handy to save bits in animations that don't change much.
|
||||||
bool GifWriteFrame( GifWriter *writer, const uint8_t *image,
|
bool GifWriteFrame(GifWriter *writer, const uint8_t *image,
|
||||||
uint32_t width, uint32_t height,
|
uint32_t width, uint32_t height,
|
||||||
uint32_t delay, int bitDepth = 8, bool dither = false )
|
uint32_t delay, int bitDepth = 8, bool dither = false) {
|
||||||
{
|
if (!writer->f) {
|
||||||
if(!writer->f) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,7 +750,7 @@ public:
|
|||||||
GifPalette pal;
|
GifPalette pal;
|
||||||
GifMakePalette((dither ? NULL : oldImage), image, width, height, bitDepth, dither, &pal);
|
GifMakePalette((dither ? NULL : oldImage), image, width, height, bitDepth, dither, &pal);
|
||||||
|
|
||||||
if(dither) {
|
if (dither) {
|
||||||
GifDitherImage(oldImage, image, writer->oldImage, width, height, &pal);
|
GifDitherImage(oldImage, image, writer->oldImage, width, height, &pal);
|
||||||
} else {
|
} else {
|
||||||
GifThresholdImage(oldImage, image, writer->oldImage, width, height, &pal);
|
GifThresholdImage(oldImage, image, writer->oldImage, width, height, &pal);
|
||||||
@@ -783,9 +764,8 @@ public:
|
|||||||
// Writes the EOF code, closes the file handle, and frees temp memory used by a GIF.
|
// Writes the EOF code, closes the file handle, and frees temp memory used by a GIF.
|
||||||
// Many if not most viewers will still display a GIF properly if the EOF code is missing,
|
// Many if not most viewers will still display a GIF properly if the EOF code is missing,
|
||||||
// but it's still a good idea to write it out.
|
// but it's still a good idea to write it out.
|
||||||
bool GifEnd( GifWriter *writer )
|
bool GifEnd(GifWriter *writer) {
|
||||||
{
|
if (!writer->f) {
|
||||||
if(!writer->f) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class GifWidget : public QDialog
|
|||||||
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
|
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
|
||||||
Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)
|
Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,12 @@ DESTDIR = $$PWD/../bin
|
|||||||
CONFIG += warn_off
|
CONFIG += warn_off
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
SOURCES += frmgifwidget.cpp
|
||||||
SOURCES += gifwidget.cpp
|
SOURCES += gifwidget.cpp
|
||||||
|
|
||||||
HEADERS += gifwidget.h
|
HEADERS += gifwidget.h
|
||||||
|
HEADERS += frmgifwidget.h
|
||||||
HEADERS += gif.h
|
HEADERS += gif.h
|
||||||
|
|
||||||
|
FORMS += frmgifwidget.ui
|
||||||
RESOURCES += main.qrc
|
RESOURCES += main.qrc
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
#include "gifwidget.h"
|
#include "frmgifwidget.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@@ -25,7 +25,9 @@ int main(int argc, char *argv[])
|
|||||||
QTextCodec::setCodecForLocale(codec);
|
QTextCodec::setCodecForLocale(codec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GifWidget::Instance()->show();
|
frmGifWidget w;
|
||||||
|
w.setWindowTitle("GIF录屏");
|
||||||
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
#include "ui_frmmaskwidget.h"
|
#include "ui_frmmaskwidget.h"
|
||||||
#include "maskwidget.h"
|
#include "maskwidget.h"
|
||||||
#include "qdialog.h"
|
#include "qdialog.h"
|
||||||
|
#include "qtimer.h"
|
||||||
|
#include "qdebug.h"
|
||||||
|
|
||||||
frmMaskWidget::frmMaskWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmMaskWidget)
|
frmMaskWidget::frmMaskWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmMaskWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
MaskWidget::Instance()->setMainWidget(this);
|
QTimer::singleShot(1000, this, SLOT(initForm()));
|
||||||
MaskWidget::Instance()->setDialogNames(QStringList() << "frmTest");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frmMaskWidget::~frmMaskWidget()
|
frmMaskWidget::~frmMaskWidget()
|
||||||
@@ -18,6 +19,12 @@ frmMaskWidget::~frmMaskWidget()
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void frmMaskWidget::initForm()
|
||||||
|
{
|
||||||
|
MaskWidget::Instance()->setMainWidget(this->topLevelWidget());
|
||||||
|
MaskWidget::Instance()->setDialogNames(QStringList() << "frmTest");
|
||||||
|
}
|
||||||
|
|
||||||
void frmMaskWidget::on_pushButton_clicked()
|
void frmMaskWidget::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
QDialog d;
|
QDialog d;
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ public:
|
|||||||
explicit frmMaskWidget(QWidget *parent = 0);
|
explicit frmMaskWidget(QWidget *parent = 0);
|
||||||
~frmMaskWidget();
|
~frmMaskWidget();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pushButton_clicked();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::frmMaskWidget *ui;
|
Ui::frmMaskWidget *ui;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void initForm();
|
||||||
|
void on_pushButton_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRMMASKWIDGET_H
|
#endif // FRMMASKWIDGET_H
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>131</width>
|
<width>92</width>
|
||||||
<height>23</height>
|
<height>28</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>弹出遮罩窗体</string>
|
<string>弹出</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
class frmMoveWidget;
|
||||||
class frmMoveWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class frmMoveWidget : public QWidget
|
class frmMoveWidget : public QWidget
|
||||||
|
|||||||
@@ -55,14 +55,6 @@ bool MoveWidget::eventFilter(QObject *watched, QEvent *event)
|
|||||||
return QObject::eventFilter(watched, event);
|
return QObject::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveWidget::setWidget(QWidget *widget)
|
|
||||||
{
|
|
||||||
if (this->widget == 0) {
|
|
||||||
this->widget = widget;
|
|
||||||
this->widget->installEventFilter(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveWidget::setLeftButton(bool leftButton)
|
void MoveWidget::setLeftButton(bool leftButton)
|
||||||
{
|
{
|
||||||
this->leftButton = leftButton;
|
this->leftButton = leftButton;
|
||||||
@@ -72,3 +64,11 @@ void MoveWidget::setInControl(bool inControl)
|
|||||||
{
|
{
|
||||||
this->inControl = inControl;
|
this->inControl = inControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveWidget::setWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
if (this->widget == 0) {
|
||||||
|
this->widget = widget;
|
||||||
|
this->widget->installEventFilter(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,21 +3,15 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用控件移动类 作者:feiyangqingyun(QQ:517216493) 2019-9-28
|
* 通用控件移动类 作者:feiyangqingyun(QQ:517216493) 2019-9-28
|
||||||
* 1:可以指定需要移动的widget
|
* 1. 可以指定需要移动的widget
|
||||||
* 2:可设置是否限定鼠标左键拖动
|
* 2. 可设置是否限定鼠标左键拖动
|
||||||
* 3:支持任意widget控件
|
* 3. 支持任意widget控件
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#ifdef quc
|
#ifdef quc
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
|
class Q_DECL_EXPORT MoveWidget : public QObject
|
||||||
#include <QtDesigner/QDesignerExportWidget>
|
|
||||||
#else
|
|
||||||
#include <QtUiPlugin/QDesignerExportWidget>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QDESIGNER_WIDGET_EXPORT MoveWidget : public QObject
|
|
||||||
#else
|
#else
|
||||||
class MoveWidget : public QObject
|
class MoveWidget : public QObject
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "frmpngtool.h"
|
#pragma execution_character_set("utf-8")
|
||||||
|
#include "frmpngtool.h"
|
||||||
#include "ui_frmpngtool.h"
|
#include "ui_frmpngtool.h"
|
||||||
#include "qfile.h"
|
#include "qfile.h"
|
||||||
#include "qfiledialog.h"
|
#include "qfiledialog.h"
|
||||||
@@ -40,7 +41,7 @@ void frmPngTool::on_btnOk_clicked()
|
|||||||
|
|
||||||
//将单个文件加入队列
|
//将单个文件加入队列
|
||||||
QString currentFile = ui->txtFile->text().trimmed();
|
QString currentFile = ui->txtFile->text().trimmed();
|
||||||
if (currentFile.isEmpty()) {
|
if (!currentFile.isEmpty()) {
|
||||||
files.append(currentFile);
|
files.append(currentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +52,6 @@ void frmPngTool::on_btnOk_clicked()
|
|||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << "*.png";
|
filter << "*.png";
|
||||||
QStringList list = imagePath.entryList(filter);
|
QStringList list = imagePath.entryList(filter);
|
||||||
|
|
||||||
foreach (QString str, list) {
|
foreach (QString str, list) {
|
||||||
files.append(currentDir + "/" + str);
|
files.append(currentDir + "/" + str);
|
||||||
}
|
}
|
||||||
@@ -60,9 +60,10 @@ void frmPngTool::on_btnOk_clicked()
|
|||||||
ui->progress->setRange(0, files.count());
|
ui->progress->setRange(0, files.count());
|
||||||
ui->progress->setValue(0);
|
ui->progress->setValue(0);
|
||||||
|
|
||||||
|
ui->txtMain->clear();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (QString file, files) {
|
foreach (QString file, files) {
|
||||||
qDebug() << "current file:" << file;
|
ui->txtMain->append(file);
|
||||||
QImage image(file);
|
QImage image(file);
|
||||||
image.save(file, "png");
|
image.save(file, "png");
|
||||||
count++;
|
count++;
|
||||||
@@ -70,5 +71,5 @@ void frmPngTool::on_btnOk_clicked()
|
|||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "finsh";
|
ui->txtMain->append(QString("处理完成, 共 %1 个文件").arg(files.count()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,24 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>437</width>
|
<width>800</width>
|
||||||
<height>105</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLineEdit" name="txtFile"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="btnOk">
|
||||||
|
<property name="text">
|
||||||
|
<string>执行转换</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLineEdit" name="txtDir"/>
|
<widget class="QLineEdit" name="txtDir"/>
|
||||||
</item>
|
</item>
|
||||||
@@ -24,9 +34,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLineEdit" name="txtFile"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="btnFile">
|
<widget class="QPushButton" name="btnFile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -37,29 +44,15 @@
|
|||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QProgressBar" name="progress">
|
<widget class="QProgressBar" name="progress">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>24</number>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="btnOk">
|
<widget class="QTextEdit" name="txtMain"/>
|
||||||
<property name="text">
|
|
||||||
<string>执行转换</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
18
screenwidget/frmscreenwidget.cpp
Normal file
18
screenwidget/frmscreenwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "frmscreenwidget.h"
|
||||||
|
#include "ui_frmscreenwidget.h"
|
||||||
|
#include "screenwidget.h"
|
||||||
|
|
||||||
|
frmScreenWidget::frmScreenWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmScreenWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
frmScreenWidget::~frmScreenWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frmScreenWidget::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
ScreenWidget::Instance()->showFullScreen();
|
||||||
|
}
|
||||||
25
screenwidget/frmscreenwidget.h
Normal file
25
screenwidget/frmscreenwidget.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef FRMSCREENWIDGET_H
|
||||||
|
#define FRMSCREENWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class frmScreenWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class frmScreenWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit frmScreenWidget(QWidget *parent = 0);
|
||||||
|
~frmScreenWidget();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::frmScreenWidget *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FRMSCREENWIDGET_H
|
||||||
32
screenwidget/frmscreenwidget.ui
Normal file
32
screenwidget/frmscreenwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>frmScreenWidget</class>
|
||||||
|
<widget class="QWidget" name="frmScreenWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>92</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>弹出</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
#include "screenwidget.h"
|
#include "frmscreenwidget.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QIcon>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -24,7 +23,9 @@ int main(int argc, char *argv[])
|
|||||||
QTextCodec::setCodecForLocale(codec);
|
QTextCodec::setCodecForLocale(codec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScreenWidget::Instance()->showFullScreen();
|
frmScreenWidget w;
|
||||||
|
w.setWindowTitle("屏幕截图");
|
||||||
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ protected:
|
|||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void saveScreen();
|
void saveScreen();
|
||||||
void saveFullScreen();
|
void saveFullScreen();
|
||||||
void saveScreenOther();
|
void saveScreenOther();
|
||||||
void saveFullOther();
|
void saveFullOther();
|
||||||
|
|||||||
@@ -14,5 +14,10 @@ DESTDIR = $$PWD/../bin
|
|||||||
CONFIG += warn_off
|
CONFIG += warn_off
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
SOURCES += frmscreenwidget.cpp
|
||||||
SOURCES += screenwidget.cpp
|
SOURCES += screenwidget.cpp
|
||||||
|
|
||||||
HEADERS += screenwidget.h
|
HEADERS += screenwidget.h
|
||||||
|
HEADERS += frmscreenwidget.h
|
||||||
|
|
||||||
|
FORMS += frmscreenwidget.ui
|
||||||
|
|||||||
Reference in New Issue
Block a user