diff --git a/colorpicker.cpp b/colorpicker.cpp index 4140850..daf6113 100755 --- a/colorpicker.cpp +++ b/colorpicker.cpp @@ -261,6 +261,12 @@ void ColorpickerPrivate::init() { mac::setDarkAppearance(); + // icc profile + ICCTransform* transform = ICCTransform::instance(); + QDir resources(QApplication::applicationDirPath() + "/../Resources"); + QString inputProfile = resources.filePath("sRGB2014.icc"); // built-in Qt input profile + transform->setInputProfile(inputProfile); + profile(); // ui ui.reset(new Ui_Colorpicker()); ui->setupUi(window); @@ -382,12 +388,8 @@ ColorpickerPrivate::init() connect(this, &ColorpickerPrivate::readOnly, ui->s, &Label::setReadOnly); connect(this, &ColorpickerPrivate::readOnly, ui->v, &Label::setReadOnly); size = window->size(); - // icc profile - ICCTransform* transform = ICCTransform::instance(); - QDir resources(QApplication::applicationDirPath() + "/../Resources"); - QString inputProfile = resources.filePath("sRGB2014.icc"); // built-in Qt input profile - transform->setInputProfile(inputProfile); - profile(); + // stylesheet + stylesheet(); // debug #ifdef QT_DEBUG QMenu* menu = ui->menubar->addMenu("Debug"); @@ -472,7 +474,6 @@ ColorpickerPrivate::grabBuffer(QRect rect) } QImage buffer; const QBrush blackBrush = QBrush(Qt::black); - QScreen* screen = QGuiApplication::screenAt(rect.center()); buffer = mac::grabImage(x, y, w, h, id); QRegion geom(x, y, w, h); @@ -656,8 +657,8 @@ ColorpickerPrivate::widget() QColor color = dragcolor; // icc profile ICCTransform* transform = ICCTransform::instance(); - if (state.iccProfile != transform->outputProfile()) { - color = transform->transformTo(color.rgb(), iccProfile, transform->outputProfile()); + if (iccCurrentProfile != transform->outputProfile()) { + color = transform->transformTo(color.rgb(), iccCurrentProfile, transform->outputProfile()); } colors.push_back(QPair(color.rgb(), QFileInfo(iccCurrentProfile).baseName())); } @@ -708,7 +709,6 @@ ColorpickerPrivate::profile() // icc profile ICCTransform* transform = ICCTransform::instance(); transform->setOutputProfile(outputProfile); - stylesheet(); } void @@ -759,6 +759,7 @@ ColorpickerPrivate::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::ScreenChangeInternal) { profile(); + stylesheet(); if (active) { view(); widget(); @@ -932,7 +933,6 @@ ColorpickerPrivate::drag() if (rect.width() > 5 && rect.height() > 5) // cluster limit { int width = image.width(); - int height = image.height(); int colornum = 6; { cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_SILENT); diff --git a/colorpicker.mm b/colorpicker.mm index a1ffdf4..df254c6 100755 --- a/colorpicker.mm +++ b/colorpicker.mm @@ -15,7 +15,6 @@ { static QMutex mutex; static QPoint lastpos; - NSApplication* app = [NSApplication sharedApplication]; [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationDidBecomeActiveNotification object:nil queue:nil diff --git a/colorwheel.cpp b/colorwheel.cpp index 183f46d..aed70c1 100755 --- a/colorwheel.cpp +++ b/colorwheel.cpp @@ -343,7 +343,6 @@ ColorwheelPrivate::paintColorwheel(int w, int h, qreal dpr) QPointF center(w/2.0, h/2.0); int diameter = std::min(w, h); int radius = diameter/2.0; - QPixmap colorwheel(w * dpr, h * dpr); colorwheel.fill(Qt::transparent); colorwheel.setDevicePixelRatio(dpr); diff --git a/dragger.cpp b/dragger.cpp index 1f53db4..565f7cc 100755 --- a/dragger.cpp +++ b/dragger.cpp @@ -82,8 +82,8 @@ DraggerPrivate::mapToGeometry() QSize size = mapToSize(); int x = position.x() - size.width() / 2; int y = position.y() - size.height() / 2; - int width = baseRect.width(); - int height = baseRect.height(); + int width; + int height; QRect screenGeometry = screen->geometry(); // left diff --git a/icctransform.cpp b/icctransform.cpp index 92fe12c..748651b 100644 --- a/icctransform.cpp +++ b/icctransform.cpp @@ -186,19 +186,19 @@ ICCTransform::ICCTransform::transformTo(QRgb color) } QImage -ICCTransform::ICCTransform::transformTo(QImage image) +ICCTransform::ICCTransform::transformTo(const QImage& image) { return p->transformTo(image, p->inputProfile, p->outputProfile); } QRgb -ICCTransform::ICCTransform::transformTo(QRgb color, QString inputProfile, QString outputProfile) +ICCTransform::ICCTransform::transformTo(QRgb color, const QString& inputProfile, const QString& outputProfile) { return p->transformTo(color, inputProfile, outputProfile); } QImage -ICCTransform::transformTo(QImage image, QString inputProfile, QString outputProfile) +ICCTransform::transformTo(const QImage& image, const QString& inputProfile, const QString& outputProfile) { return p->transformTo(image, inputProfile, outputProfile); } diff --git a/icctransform.h b/icctransform.h index cd0b1aa..59a10eb 100644 --- a/icctransform.h +++ b/icctransform.h @@ -20,9 +20,9 @@ class ICCTransform : public QObject QString inputProfile() const; QString outputProfile() const; QRgb transformTo(QRgb image); - QImage transformTo(QImage image); - QRgb transformTo(QRgb color, QString profile, QString outputProfile); - QImage transformTo(QImage image, QString profile, QString outputProfile); + QImage transformTo(const QImage& image); + QRgb transformTo(QRgb color, const QString& profile, const QString& outputProfile); + QImage transformTo(const QImage& image, const QString& profile, const QString& outputProfile); public Q_SLOTS: void setInputProfile(const QString& inputProfile); diff --git a/mac.mm b/mac.mm index 59500df..7636992 100755 --- a/mac.mm +++ b/mac.mm @@ -112,6 +112,7 @@ ColorSyncProfile grabColorSyncProfile(NSScreen* screen) if (iccURLRef) { colorSyncProfile.displayProfileUrl = CFURLCopyFileSystemPath(iccURLRef, kCFURLPOSIXPathStyle); } + CFRelease(csProfileRef); } return colorSyncProfile; } @@ -166,7 +167,11 @@ QImage grabImage(int x, int y, int width, int height, WId windowId) CGRect cgRect = (width < 0 || height < 0) ? CGRectInfinite : grabRect.toCGRect(); const CGDisplayErr err = CGGetDisplaysWithRect(cgRect, maxDisplays, displays, &displayCount); if (err || displayCount == 0) + { + CFRelease(screenWindows); + CFRelease(grabWindows); return QImage(); + } // if the grab size is not specified, set it to be the bounding box of all screens, if (width < 0 || height < 0) { diff --git a/picker.cpp b/picker.cpp index 2817796..f241c89 100755 --- a/picker.cpp +++ b/picker.cpp @@ -62,8 +62,8 @@ PickerPrivate::mapToGeometry() int x = position.x() - size.width() / 2; int y = position.y() - size.height() / 2; - int width = widget->width(); - int height = widget->height(); + int width; + int height; QRect screenGeometry = screen->geometry(); // left if (x < screenGeometry.left()) {