.TH "KPixmapIO" 3 "28 Jan 2004" "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
.RI "\fIShared memory allocation policies. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBQPixmap\fP \fBconvertToPixmap\fP (const  \fBQImage\fP &image)"
.br
.RI "\fIConvert an image to a pixmap. \fP"
.ti -1c
.RI "\fBQImage\fP \fBconvertToImage\fP (const  \fBQPixmap\fP &pixmap)"
.br
.RI "\fIConvert a pixmap to an image. \fP"
.ti -1c
.RI "void \fBputImage\fP (\fBQPixmap\fP *dst, int dx, int dy, const  \fBQImage\fP *src)"
.br
.RI "\fIBitblt an image onto a pixmap. \fP"
.ti -1c
.RI "void \fBputImage\fP (\fBQPixmap\fP *dst, const  \fBQPoint\fP &offset, const  \fBQImage\fP *src)"
.br
.RI "\fIThis function is identical to the one above. \fP"
.ti -1c
.RI "\fBQImage\fP \fBgetImage\fP (const  \fBQPixmap\fP *src, int sx, int sy, int sw, int sh)"
.br
.RI "\fITransfer (a part of) a pixmap to an image. \fP"
.ti -1c
.RI "\fBQImage\fP \fBgetImage\fP (const  \fBQPixmap\fP *src, const  \fBQRect\fP &rect)"
.br
.RI "\fIThis function is identical to the one above. \fP"
.ti -1c
.RI "void \fBsetShmPolicy\fP (int policy)"
.br
.RI "\fISet the shared memory allocation policy. \fP"
.ti -1c
.RI "void \fBpreAllocShm\fP (int size)"
.br
.RI "\fIPre-allocate shared memory. \fP"
.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,v 1.8.2.2 2003/06/05 23:42:37 mueller Exp 
.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
\fB Typical usage\fP
.PP
\fB You can use KPixmapIO for load/saving pixmaps.\fP
.PP
\fB 
.PP
.nf

 KPixmapIO io;
 pixmap = io.convertToPixmap(image);
 image = io.convertToImage(pixmap);
 
.PP
\fP
.PP
\fB It also has functionality for partially updating/saving pixmaps, see \fBputImage\fP and \fBgetImage\fP.\fP
.PP
\fB \fP
.PP
\fB\fB KPixmapIO vs. \fBQt\fP speed comparison\fP\fP
.PP
\fB\fB 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.\fP\fP
.PP
\fB\fB 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.\fP\fP
.PP
\fB\fB 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.\fP\fP
.PP
\fB\fB When the policy is \fCShmKeepAndGrow\fP, the threshold is taken at 2.000 pixels. Using this policy, you might want to use \fBpreAllocShm\fP 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.\fP\fP
.PP
\fB\fB 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.\fP\fP
.PP
\fB\fB 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.\fP\fP
.PP
\fB\fB \fP\fP
.PP
\fB\fB\fB Conclusion\fP\fP\fP
.PP
\fB\fB\fB 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. \fP\fP\fP
.PP
Definition at line 86 of file kpixmapio.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "enum \fBKPixmapIO::ShmPolicies\fP"
.PP
Shared memory allocation policies. Definition at line 141 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. \fBParameters:\fP
.RS 4
\fIimage\fP The image to convert. 
.RE
.PP
\fBReturns:\fP
.RS 4
The pixmap containing the image. 
.RE
.PP
Definition at line 178 of file kpixmapio.cpp.
.PP
References QPixmap::convertFromImage(), QImage::depth(), QImage::height(), putImage(), and QImage::width().
.PP
Referenced by KRootPixmap::updateBackground().
.SS "\fBQImage\fP KPixmapIO::convertToImage (const \fBQPixmap\fP & pixmap)"
.PP
Convert a pixmap to an image. \fBParameters:\fP
.RS 4
\fIpixmap\fP The pixmap to convert. 
.RE
.PP
\fBReturns:\fP
.RS 4
The image. 
.RE
.PP
Definition at line 196 of file kpixmapio.cpp.
.PP
References QPixmap::convertToImage(), getImage(), QPixmap::height(), and QPixmap::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. \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
Definition at line 215 of file kpixmapio.cpp.
.PP
References QPixmap::convertFromImage(), QImage::depth(), 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. It only differs in the arguments it accepts. Definition at line 208 of file kpixmapio.cpp.
.PP
References putImage(), QPoint::x(), and QPoint::y().
.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. \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
Definition at line 253 of file kpixmapio.cpp.
.PP
References QPixmap::convertToImage(), QPixmap::height(), and QPixmap::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. It only differs in the arguments it accepts. Definition at line 247 of file kpixmapio.cpp.
.PP
References getImage(), QRect::height(), QRect::width(), QRect::x(), and QRect::y().
.SS "void KPixmapIO::setShmPolicy (int policy)"
.PP
Set the shared memory allocation policy. See the introduction for KPixmapIO for a discussion. 
.PP
\fBParameters:\fP
.RS 4
\fIpolicy\fP The alloction policy. 
.RE
.PP
Definition at line 860 of file kpixmapio.cpp.
.SS "void KPixmapIO::preAllocShm (int size)"
.PP
Pre-allocate shared memory. 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
Definition at line 859 of file kpixmapio.cpp.

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