diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index c05ba06146..e8904dff06 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -182,6 +182,24 @@ QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size) #endif // Q_OS_MACOS +#ifdef Q_OS_IOS + +QImage qt_mac_toQImage(const UIImage *image, QSizeF size) +{ + QImage ret(size.width(), size.height(), QImage::Format_ARGB32_Premultiplied); + ret.fill(Qt::transparent); + QMacCGContext ctx(&ret); + if (!ctx) + return QImage(); + UIGraphicsPushContext(ctx); + const CGRect rect = CGRectMake(0, 0, size.width(), size.height()); + [image drawInRect:rect]; + UIGraphicsPopContext(); + return ret; +} + +#endif // Q_OS_IOS + // ---------------------- Colors and Brushes ---------------------- QColor qt_mac_toQColor(CGColorRef color) diff --git a/src/gui/painting/qcoregraphics_p.h b/src/gui/painting/qcoregraphics_p.h index f0640ba500..f2c2ba1db1 100644 --- a/src/gui/painting/qcoregraphics_p.h +++ b/src/gui/painting/qcoregraphics_p.h @@ -23,15 +23,24 @@ #include -#if defined(__OBJC__) && defined(Q_OS_MACOS) -#include -#define HAVE_APPKIT +#if defined(__OBJC__) +# if defined(Q_OS_MACOS) +# include +# define HAVE_APPKIT +# elif defined(Q_OS_IOS) +# include +# define HAVE_UIKIT +# endif #endif QT_BEGIN_NAMESPACE Q_GUI_EXPORT CGBitmapInfo qt_mac_bitmapInfoForImage(const QImage &image); +#ifdef HAVE_UIKIT +Q_GUI_EXPORT QImage qt_mac_toQImage(const UIImage *image, QSizeF size); +#endif + #ifdef HAVE_APPKIT Q_GUI_EXPORT QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);