Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcoregraphics_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QCOREGRAPHICS_P_H
6#define QCOREGRAPHICS_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qcore_mac_p.h>
20
21#include <QtCore/qsize.h>
22
23#include <QtGui/private/qtguiglobal_p.h>
24#include <QtGui/qicon.h>
25#include <QtGui/qpalette.h>
26#include <QtGui/qregion.h>
27
28#include <CoreGraphics/CoreGraphics.h>
29
30#if defined(Q_OS_MACOS)
31# if defined(__OBJC__)
32# include <AppKit/NSImage.h>
33# else
34Q_FORWARD_DECLARE_OBJC_CLASS(NSImage);
35# endif
36#endif
37
40
42
44{
45 uint32_t bitsPerComponent = 0;
46 uint32_t bitsPerPixel = 0;
47 QCFType<CGColorSpaceRef> colorSpace;
48 CGBitmapInfo bitmapInfo = 0;
49};
50
51Q_GUI_EXPORT std::optional<QCGImageFormat> qt_mac_cgImageFormatForImage(const QImage &image);
52
53#ifdef QT_PLATFORM_UIKIT
54Q_GUI_EXPORT QImage qt_mac_toQImage(const UIImage *image, QSizeF size);
55#endif
56
57#ifdef Q_OS_MACOS
58Q_GUI_EXPORT QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);
59
60#if defined(__OBJC__)
61QT_END_NAMESPACE
62
63// @compatibility_alias doesn't work with categories or their methods
64#define imageFromQImage QT_MANGLE_NAMESPACE(imageFromQImage)
65#define imageFromQIcon QT_MANGLE_NAMESPACE(imageFromQIcon)
66
67@interface NSImage (QtExtras)
68+ (instancetype)imageFromQImage:(const QT_PREPEND_NAMESPACE(QImage) &)image;
69+ (instancetype)imageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon;
70+ (instancetype)imageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon
71 withSize:(const QT_PREPEND_NAMESPACE(QSize) &)size;
72+ (instancetype)imageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon
73 withSize:(const QT_PREPEND_NAMESPACE(QSize) &)size
74 withMode:(QT_PREPEND_NAMESPACE(QIcon)::Mode)mode
75 withState:(QT_PREPEND_NAMESPACE(QIcon)::State)state;
76+ (instancetype)internalImageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon;
77@end
78QT_BEGIN_NAMESPACE
79#endif // __OBJC__
80
81#endif
82Q_GUI_EXPORT CGImageRef qt_mac_toCGImage(const QImage &qImage);
83Q_GUI_EXPORT QImage qt_mac_toQImage(CGImageRef image);
84
85Q_GUI_EXPORT QImage qt_mac_padToSquareImage(const QImage &image);
86
87Q_GUI_EXPORT void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);
88
89Q_GUI_EXPORT void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform);
90
91#ifdef Q_OS_MACOS
92Q_GUI_EXPORT QColor qt_mac_toQColor(const NSColor *color);
93Q_GUI_EXPORT QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup = QPalette::Normal);
94#endif
95Q_GUI_EXPORT QColor qt_mac_toQColor(CGColorRef color);
96Q_GUI_EXPORT QBrush qt_mac_toQBrush(CGColorRef color);
97
98class Q_GUI_EXPORT QMacCGContext
99{
100public:
101 QMacCGContext() = default;
102 QMacCGContext(QPaintDevice *pdev);
103 QMacCGContext(QPainter *p);
104
105 operator CGContextRef() { return context; }
106
107private:
108 void initialize(QPaintDevice *paintDevice);
109 void initialize(const QImage *, QPainter *painter = nullptr);
110 QCFType<CGContextRef> context;
111};
112
113QT_END_NAMESPACE
114
115#endif // QCOREGRAPHICS_P_H
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qimage.h:38
void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
QBrush qt_mac_toQBrush(CGColorRef color)
QImage::Format qt_mac_imageFormatForCGImage(CGImageRef image)
void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
QColor qt_mac_toQColor(CGColorRef color)
void qt_mac_scale_region(QRegion *region, qreal scaleFactor)
QImage qt_mac_toQImage(CGImageRef cgImage)
CGImageRef qt_mac_toCGImage(const QImage &inImage)
QImage qt_mac_padToSquareImage(const QImage &image)
Q_FORWARD_DECLARE_OBJC_CLASS(UIImage)
Q_FORWARD_DECLARE_OBJC_CLASS(NSColor)