46 #include "private/qpaintengine_raster_p.h" 48 #include "private/qapplication_p.h" 49 #include "private/qgraphicssystem_p.h" 51 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) 59 #include <private/qpaintengine_mac_p.h> 79 memset(&bmi, 0,
sizeof(bmi));
80 bmi.
bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
97 bmi.
bmiHeader.biCompression = BI_BITFIELDS;
110 HDC display_dc = GetDC(0);
111 hdc = CreateCompatibleDC(display_dc);
112 ReleaseDC(0, display_dc);
116 bitmap = CreateDIBSection(
hdc, reinterpret_cast<BITMAPINFO *>(&bmi), DIB_RGB_COLORS, (
void**) &bits, 0, 0);
151 #elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM) 154 : xshmimg(0), xshmpm(0)
158 int dd = info.
depth();
159 Visual *vis = (Visual*) info.
visual();
164 xshminfo.readOnly =
true;
165 xshminfo.shmaddr = 0;
171 xshmimg = XShmCreateImage(
X11->display, vis, dd, ZPixmap, 0, &xshminfo,
width,
height);
173 qWarning(
"QNativeImage: Unable to create shared XImage.");
178 xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height,
180 ok = xshminfo.shmid != -1;
182 xshmimg->data = (
char*)shmat(xshminfo.shmid, 0, 0);
183 xshminfo.shmaddr = xshmimg->data;
184 ok = (xshminfo.shmaddr != (
char*)-1);
188 xshminfo.readOnly =
false;
190 ok = XShmAttach(
X11->display, &xshminfo);
191 XSync(
X11->display, False);
192 if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
193 qWarning() <<
"Error while marking the shared memory segment to be destroyed";
196 qWarning() <<
"QNativeImage: Unable to attach to shared memory segment.";
201 XDestroyImage(xshmimg);
203 if (xshminfo.shmaddr)
204 shmdt(xshminfo.shmaddr);
205 if (xshminfo.shmid != -1)
206 shmctl(xshminfo.shmid, IPC_RMID, 0);
209 if (
X11->use_mitshm_pixmaps) {
210 xshmpm = XShmCreatePixmap(
X11->display, DefaultRootWindow(
X11->display), xshmimg->data,
213 qWarning() <<
"QNativeImage: Unable to create shared Pixmap.";
225 XFreePixmap(
X11->display, xshmpm);
228 XShmDetach(
X11->display, &xshminfo);
230 XDestroyImage(xshmimg);
232 shmdt(xshminfo.shmaddr);
233 shmctl(xshminfo.shmid, IPC_RMID, 0);
243 #elif defined(Q_WS_MAC) 249 uint cgflags = kCGImageAlphaNoneSkipFirst;
252 cgflags = kCGImageAlphaFirst;
259 cgflags = kCGImageAlphaPremultipliedFirst;
265 #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version 266 cgflags |= kCGBitmapByteOrder32Host;
271 CGContextTranslateCTM(cg, 0, height);
272 CGContextScaleCTM(cg, 1, -1);
281 CGContextRelease(cg);
290 #else // other platforms... 306 return QApplicationPrivate::platformIntegration()->screens().at(0)->format();
int depth() const
Returns the color depth (bits per pixel) of the X display.
static CGColorSpaceRef macDisplayColorSpace(const QWidget *widget=0)
Format
The following image formats are available in Qt.
static QColormap instance(int screen=-1)
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer=false, QWidget *widget=0)
int bytesPerLine() const
Returns the number of bytes per image scanline.
static QImage::Format systemFormat()
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
void * visual() const
Returns the current visual.
uchar * bits()
Returns a pointer to the first pixel data.
The QX11Info class provides information about the X display configuration.
QPaintEngine * paintEngine() const
Used by QPainter to retrieve a paint engine for the image.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
BITMAPINFOHEADER bmiHeader