mirror of
https://gitlab.com/eql/EQL5.git
synced 2025-12-20 01:00:26 -08:00
add module :quick (quick, quickwidgets, qml) plus an example; lots of small revisions;
This commit is contained in:
parent
4822a012c4
commit
dfccd7eb17
102 changed files with 11973 additions and 6852 deletions
31
examples/X-extras/qimage/cpp/lib.cpp
Normal file
31
examples/X-extras/qimage/cpp/lib.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "lib.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QObject* ini() {
|
||||
static CPP* cpp = 0;
|
||||
if(!cpp) {
|
||||
cpp = new CPP; }
|
||||
return cpp; }
|
||||
|
||||
static void _toGrayscale(QImage* image) {
|
||||
if(image) {
|
||||
// stolen from Stack Overflow
|
||||
for(int y = 0; y < image->height(); y++) {
|
||||
uchar* scan = image->scanLine(y);
|
||||
int depth = 4;
|
||||
for(int x = 0; x < image->width(); x++) {
|
||||
QRgb* rgbpixel = reinterpret_cast<QRgb*>(scan + x * depth);
|
||||
int gray = qGray(*rgbpixel);
|
||||
*rgbpixel = QColor(gray, gray, gray).rgba(); }}}}
|
||||
|
||||
QImage CPP::toGrayscale(const QImage& image) {
|
||||
QImage image2 = image;
|
||||
image2.detach();
|
||||
_toGrayscale(&image2);
|
||||
return image2; }
|
||||
|
||||
void CPP::toGrayscaleReplace(QImage* image) {
|
||||
_toGrayscale(image); }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
Loading…
Add table
Add a link
Reference in a new issue