.TH "KPixmapIO" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdeui Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KPixmapIO \- Fast \fBQImage\fP to/from \fBQPixmap\fP conversion.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kpixmapio.h>\fP
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "enum \fBShmPolicies\fP { \fBShmDontKeep\fP, \fBShmKeepAndGrow\fP }"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBQPixmap\fP \fBconvertToPixmap\fP (const \fBQImage\fP &image)"
.br
.ti -1c
.RI "\fBQImage\fP \fBconvertToImage\fP (const \fBQPixmap\fP &pixmap)"
.br
.ti -1c
.RI "void \fBputImage\fP (\fBQPixmap\fP *dst, int dx, int dy, const \fBQImage\fP *src)"
.br
.ti -1c
.RI "void \fBputImage\fP (\fBQPixmap\fP *dst, const \fBQPoint\fP &offset, const \fBQImage\fP *src)"
.br
.ti -1c
.RI "\fBQImage\fP \fBgetImage\fP (const \fBQPixmap\fP *src, int sx, int sy, int sw, int sh)"
.br
.ti -1c
.RI "\fBQImage\fP \fBgetImage\fP (const \fBQPixmap\fP *src, const \fBQRect\fP &rect)"
.br
.ti -1c
.RI "void \fBsetShmPolicy\fP (int policy)"
.br
.ti -1c
.RI "void \fBpreAllocShm\fP (int size)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Fast \fBQImage\fP to/from \fBQPixmap\fP conversion. 

\fBAuthor:\fP
.RS 4
Geert Jansen <jansen@kde.org> 
.RE
.PP
\fBVersion:\fP
.RS 4
\fBId\fP.RS 4
\fBkpixmapio.h\fP 345236 2004-09-09 15:23:55Z dfaure 
.RE
.PP
.RE
.PP
KPixmapIO implements a fast path for \fBQPixmap\fP to/from \fBQImage\fP conversions. It uses the MIT-SHM shared memory extension for this. If this extension is not available, it will fall back to standard \fBQt\fP methods.
.PP
\fBTypical usage:\fP
.br
.PP
You can use KPixmapIO for load/saving pixmaps.
.PP
.PP
.nf
 KPixmapIO io;
 pixmap = io.convertToPixmap(image);
 image = io.convertToImage(pixmap);
.fi
.PP
.PP
It also has functionality for partially updating/saving pixmaps, see putImage and getImage.
.PP
\fBKPixmapIO vs. \fBQt\fP speed comparison\fP
.br
.PP
Speed measurements were taken. These show that usage of KPixmapIO for images up to a certain threshold size, offers no speed advantage over the \fBQt\fP routines. Below you can see a plot of these measurements.
.PP
Performance of KPixmapIO The threshold size, amongst other causes, is determined by the shared memory allocation policy. If the policy is \fCShmDontKeep\fP, the shared memory segment is discarded right after usage, and thus needs to be allocated before each transfer. This introduces a a setup penalty not present when the policy is \fCShmKeepAndGrow\fP. In this case the shared memory segment is kept and resized when necessary, until the KPixmapIO object is destroyed.
.PP
The default policy is \fCShmDontKeep\fP. This policy makes sense when loading pixmaps once. The corresponding threshold is taken at 5.000 pixels as suggested by experiments. Below this threshold, KPixmapIO will not use shared memory and fall back on the \fBQt\fP routines.
.PP
When the policy is \fCShmKeepAndGrow\fP, the threshold is taken at 2.000 pixels. Using this policy, you might want to use preAllocShm to pre-allocate a certain amount of shared memory, in order to avoid resizes. This allocation policy makes sense in a multimedia type application where you are constantly updating the screen.
.PP
Above a couple times the threshold size, KPixmapIO's and Qt's speed become linear in the number of pixels, KPixmapIO being at least 2, and mostly around 4 times faster than \fBQt\fP, depending on the screen and image depth.
.PP
Speed difference seems to be the most at 16 bpp, followed by 32 and 24 bpp respectively. This can be explained by the relatively poor implementation of 16 bit RGB packing in \fBQt\fP, while at 32 bpp we need to transfer more data, and thus gain more, than at 24 bpp.
.PP
\fBConclusion:\fP
.br
.PP
For large pixmaps, there's a definite speed improvement when using KPixmapIO. On the other hand, there's no speed improvement for small pixmaps. When you know you're only transferring small pixmaps, there's no point in using it. 
.PP
Definition at line 87 of file kpixmapio.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "enum \fBKPixmapIO::ShmPolicies\fP"
.PP
Shared memory allocation policies. 
.PP
Definition at line 142 of file kpixmapio.h.
.SH "Member Function Documentation"
.PP 
.SS "\fBQPixmap\fP KPixmapIO::convertToPixmap (const \fBQImage\fP & image)"
.PP
Convert an image to a pixmap. 
.PP
\fBParameters:\fP
.RS 4
\fIimage\fP The image to convert. 
.RE
.PP
\fBReturns:\fP
.RS 4
The pixmap containing the image. 
.RE
.PP

.PP
Definition at line 181 of file kpixmapio.cpp.
.PP
References QPixmap::convertFromImage(), QPixmap::height(), putImage(), and QPixmap::width().
.PP
Referenced by KRootPixmap::updateBackground().
.SS "\fBQImage\fP KPixmapIO::convertToImage (const \fBQPixmap\fP & pixmap)"
.PP
Convert a pixmap to an image. 
.PP
\fBParameters:\fP
.RS 4
\fIpixmap\fP The pixmap to convert. 
.RE
.PP
\fBReturns:\fP
.RS 4
The image. 
.RE
.PP

.PP
Definition at line 199 of file kpixmapio.cpp.
.PP
References getImage(), QImage::height(), and QImage::width().
.PP
Referenced by KRootPixmap::updateBackground().
.SS "void KPixmapIO::putImage (\fBQPixmap\fP * dst, int dx, int dy, const \fBQImage\fP * src)"
.PP
Bitblt an image onto a pixmap. 
.PP
\fBParameters:\fP
.RS 4
\fIdst\fP The destination pixmap. 
.br
\fIdx\fP Destination x offset. 
.br
\fIdy\fP Destination y offset. 
.br
\fIsrc\fP The image to load. 
.RE
.PP

.PP
Definition at line 218 of file kpixmapio.cpp.
.PP
References QPixmap::convertFromImage(), QPixmap::height(), QImage::height(), QPixmap::width(), and QImage::width().
.PP
Referenced by convertToPixmap(), and putImage().
.SS "void KPixmapIO::putImage (\fBQPixmap\fP * dst, const \fBQPoint\fP & offset, const \fBQImage\fP * src)"
.PP
This function is identical to the one above. 
.PP
It only differs in the arguments it accepts. 
.PP
Definition at line 211 of file kpixmapio.cpp.
.PP
References putImage().
.SS "\fBQImage\fP KPixmapIO::getImage (const \fBQPixmap\fP * src, int sx, int sy, int sw, int sh)"
.PP
Transfer (a part of) a pixmap to an image. 
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP The source pixmap. 
.br
\fIsx\fP Source x offset. 
.br
\fIsy\fP Source y offset. 
.br
\fIsw\fP Source width. 
.br
\fIsh\fP Source height. 
.RE
.PP
\fBReturns:\fP
.RS 4
The image. 
.RE
.PP

.PP
Definition at line 252 of file kpixmapio.cpp.
.PP
References QPixmap::convertToImage(), QImage::height(), and QImage::width().
.PP
Referenced by convertToImage(), and getImage().
.SS "\fBQImage\fP KPixmapIO::getImage (const \fBQPixmap\fP * src, const \fBQRect\fP & rect)"
.PP
This function is identical to the one above. 
.PP
It only differs in the arguments it accepts. 
.PP
Definition at line 246 of file kpixmapio.cpp.
.PP
References getImage().
.SS "void KPixmapIO::setShmPolicy (int policy)"
.PP
Set the shared memory allocation policy. 
.PP
See the introduction for KPixmapIO for a discussion. 
.PP
\fBParameters:\fP
.RS 4
\fIpolicy\fP The alloction policy. 
.RE
.PP

.PP
Definition at line 892 of file kpixmapio.cpp.
.SS "void KPixmapIO::preAllocShm (int size)"
.PP
Pre-allocate shared memory. 
.PP
KPixmapIO will be able to transfer images up to this size without resizing. 
.PP
\fBParameters:\fP
.RS 4
\fIsize\fP The size of the image in \fCpixels\fP. 
.RE
.PP

.PP
Definition at line 891 of file kpixmapio.cpp.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdeui Library from the source code.
