Source Code (Use browser search to find items of interest.)

Class Index

kdelibs'KPixmapIO (./kdelibs/kdeui/kpixmapio.h:81)

class KPixmapIO
{
public:
    KPixmapIO();
    ~KPixmapIO();

    /**
     * Convert an image to a pixmap.
     * @param image The image to convert.
     * @return The pixmap containing the image.
     */
    QPixmap convertToPixmap(const QImage &image);
    
    /**
     * Convert a pixmap to an image.
     * @param pixmap The pixmap to convert.
     * @return The image.
     */
    QImage convertToImage(const QPixmap &pixmap);

    /**
     * Bitblt an image onto a pixmap.
     * @param dst The destination pixmap.
     * @param dx Destination x offset.
     * @param dy Destination y offset.
     * @param src The image to load.
     */
    void putImage(QPixmap *dst, int dx, int dy, const QImage *src);

    /**
     * This function is identical to the one above. It only differs in the
     * arguments it accepts.
     */
    void putImage(QPixmap *dst, const QPoint &offset, const QImage *src);

    /**
     * Transfer (a part of) a pixmap to an image.
     * @param src The source pixmap.
     * @param sx Source x offset.
     * @param sy Source y offset.
     * @param sw Source width.
     * @param sh Source height.
     * @return The image.
     */
    QImage getImage(const QPixmap *src, int sx, int sy, int sw, int sh);

    /**
     * This function is identical to the one above. It only differs in the
     * arguments it accepts.
     */
    QImage getImage(const QPixmap *src, const QRect &rect);

    /**
     * Shared memory allocation policies.
     */
    enum ShmPolicies {
	ShmDontKeep,
	ShmKeepAndGrow
    };

    /**
     * Set the shared memory allocation policy. See the introduction for
     * KPixmapIO for a discussion.
     * @param policy The alloction policy.
     */
    void setShmPolicy(int policy);

    /**
     * Pre-allocate shared memory. KPixmapIO will be able to transfer images
     * up to this size without resizing.
     * @param size The size of the image in @em pixels.
     */
    void preAllocShm(int size);

private:
    /*
     * Supported XImage byte orders. The notation ARGB means bytes
     * containing A:R:G:B succeed in memory.
     */
    enum ByteOrders {
	bo32_ARGB, bo32_BGRA, bo24_RGB, bo24_BGR,
	bo16_RGB_565, bo16_BGR_565, bo16_RGB_555, 
	bo16_BGR_555, bo8
    };

    bool m_bShm;
    class KPixmapIOData *d;

    void initXImage(int w, int h);
    void doneXImage();
    void createXImage(int w, int h);
    void destroyXImage();
    void createShmSegment(int size);
    void destroyShmSegment();
    void convertToXImage(const QImage &);
    QImage convertFromXImage();
};

kdelibs'KPixmapIO::KPixmapIO() (./kdelibs/kdeui/kpixmapio.cpp:72)

KPixmapIO::KPixmapIO()
{
    m_bShm = false;
    d = new KPixmapIOData;
    
#ifdef HAVE_MITSHM
    setShmPolicy(ShmDontKeep);
    KConfig *config = KGlobal::config();
    if (!config->readBoolEntry("UseMitShm", true))
	return;

    int ignore;
    if (XQueryExtension(qt_xdisplay(), "MIT-SHM", &ignore, &ignore, &ignore)) {
	if (XShmQueryExtension(qt_xdisplay()))
	    m_bShm = true;
    }
    if (!m_bShm) {
	kdDebug() << "" << ID << ": MIT-SHM not available!" << endl;
	return;
    }

    // Sort out bit format. Create a temporary XImage for this.
    d->shminfo = new XShmSegmentInfo;
    d->ximage = XShmCreateImage(qt_xdisplay(), (Visual *) QPaintDevice::x11AppVisual(),
	    QPaintDevice::x11AppDepth(), ZPixmap, 0L, d->shminfo, 10, 10);
    d->bpp = d->ximage->bits_per_pixel;
    int bpp = d->bpp;
    if (d->ximage->byte_order == LSBFirst)
	bpp++;
    int red_shift = lowest_bit(d->ximage->red_mask);
    int green_shift = lowest_bit(d->ximage->green_mask);
    int blue_shift = lowest_bit(d->ximage->blue_mask);
    XDestroyImage(d->ximage); d->ximage = 0L;
    d->shmsize = 0;

    // Offer discrete possibilities for the bitformat. Each will have its
    // own routine. The general algorithm using bitshifts is much too slow;
    // this has to be done for every pixel!

    if ((bpp == 32) && (red_shift == 16) && (green_shift == 8) &&
	    (blue_shift == 0))
	d->byteorder = bo32_ARGB;
    else if ((bpp == 33) && (red_shift == 16) && (green_shift == 8) &&
	    (blue_shift == 0))
	d->byteorder = bo32_BGRA;
    else if ((bpp == 24) && (red_shift == 16) && (green_shift == 8) &&
	    (blue_shift == 0))
	d->byteorder = bo24_RGB;
    else if ((bpp == 25) && (red_shift == 16) && (green_shift == 8) &&
	    (blue_shift == 0))
	d->byteorder = bo24_BGR;
    else if ((bpp == 16) && (red_shift == 11) && (green_shift == 5) &&
	    (blue_shift == 0))
	d->byteorder = bo16_RGB_565;
    else if ((bpp == 16) && (red_shift == 10) && (green_shift == 5) &&
	    (blue_shift == 0))
	d->byteorder = bo16_RGB_555;
    else if ((bpp == 17) && (red_shift == 11) && (green_shift == 5) &&
	    (blue_shift == 0))
	d->byteorder = bo16_BGR_565;
    else if ((bpp == 16) && (red_shift == 10) && (green_shift == 5) &&
	    (blue_shift == 0))
	d->byteorder = bo16_BGR_555;
    else if ((bpp == 8) || (bpp == 9))
	d->byteorder = bo8;
    else {
	m_bShm = false;
	kdWarning() << "" << ID << ": Byte order not supported!" << endl;
	kdWarning() << "" << ID << ": red = " << d->ximage->red_mask << ", green = " << d->ximage->green_mask << ", blue = " << d->ximage->blue_mask << endl;
	kdWarning() << "" << ID << ": Please report to <jansen@kde.org>" << endl;
    }
#endif
}



kdelibs'KPixmapIO::~KPixmapIO() (./kdelibs/kdeui/kpixmapio.cpp:147)

KPixmapIO::~KPixmapIO()
{
    destroyXImage();
    destroyShmSegment();
    delete d;
}



kdelibs'KPixmapIO::convertToPixmap() (./kdelibs/kdeui/kpixmapio.cpp:155)

QPixmap KPixmapIO::convertToPixmap(const QImage &img)
{
    int size = img.width() * img.height();
    if (m_bShm && (img.depth() > 1) && (d->bpp > 8) && (size > d->threshold)) {
	QPixmap dst(img.width(), img.height());
	putImage(&dst, 0, 0, &img);
	return dst;
    } else {
	QPixmap dst;
	dst.convertFromImage(img);
	return dst;
    }
	
}



kdelibs'KPixmapIO::convertToImage() (./kdelibs/kdeui/kpixmapio.cpp:171)

QImage KPixmapIO::convertToImage(const QPixmap &pm)
{
    QImage image;
    int size = pm.width() * pm.height();
    if (m_bShm && (d->bpp >= 8) && (size > d->threshold))
	image = getImage(&pm, 0, 0, pm.width(), pm.height());
    else
	image = pm.convertToImage();
    return image;
}



kdelibs'KPixmapIO::putImage() (./kdelibs/kdeui/kpixmapio.cpp:183)

void KPixmapIO::putImage(QPixmap *dst, const QPoint &offset, 
    const QImage *src)
{
    putImage(dst, offset.x(), offset.y(), src);
}



kdelibs'KPixmapIO::putImage() (./kdelibs/kdeui/kpixmapio.cpp:190)

void KPixmapIO::putImage(QPixmap *dst, int dx, int dy, const QImage *src)
{
    int size = src->width() * src->height();
    if (m_bShm && (src->depth() > 1) && (d->bpp > 8) && (size > d->threshold)) {
#ifdef HAVE_MITSHM
	initXImage(src->width(), src->height());
	convertToXImage(*src);
	XShmPutImage(qt_xdisplay(), dst->handle(), qt_xget_temp_gc(), d->ximage,
		dx, dy, 0, 0, src->width(), src->height(), false);
	XSync(qt_xdisplay(), false);
	doneXImage();
#endif
    } else {
	QPixmap pix;
	pix.convertFromImage(*src);
	bitBlt(dst, dx, dy, &pix, 0, 0, pix.width(), pix.height());
    }
}



kdelibs'KPixmapIO::getImage() (./kdelibs/kdeui/kpixmapio.cpp:210)

QImage KPixmapIO::getImage(const QPixmap *src, const QRect &rect)
{
    return getImage(src, rect.x(), rect.y(), rect.width(), rect.height());
}



kdelibs'KPixmapIO::getImage() (./kdelibs/kdeui/kpixmapio.cpp:216)

QImage KPixmapIO::getImage(const QPixmap *src, int sx, int sy, int sw, int sh)
{
    QImage image;
    int size = src->width() * src->height();
    if ((m_bShm) && (d->bpp >= 8) && (size > d->threshold)) {
#ifdef HAVE_MITSHM
	initXImage(sw, sh);
	XShmGetImage(qt_xdisplay(), src->handle(), d->ximage, sx, sy, AllPlanes);
	image = convertFromXImage();
	doneXImage();
#endif
    } else {
	QPixmap pix(sw, sh);
	bitBlt(&pix, 0, 0, src, sx, sy, sw, sh);
	image = pix.convertToImage();
    }
    return image;
}


kdelibs'KPixmapIO::preAllocShm() (./kdelibs/kdeui/kpixmapio.cpp:238)

void KPixmapIO::preAllocShm(int size)
{
    destroyXImage();
    createShmSegment(size);
}



kdelibs'KPixmapIO::setShmPolicy() (./kdelibs/kdeui/kpixmapio.cpp:245)

void KPixmapIO::setShmPolicy(int policy)
{
    switch (policy) {
    case ShmDontKeep:
	d->shmpolicy = ShmDontKeep;
	d->threshold = 5000;
	break;
    case ShmKeepAndGrow:
	d->shmpolicy = ShmKeepAndGrow;
	d->threshold = 2000;
	break;
    default:
	break;
    }
}



kdelibs'KPixmapIO::initXImage() (./kdelibs/kdeui/kpixmapio.cpp:262)

void KPixmapIO::initXImage(int w, int h)
{
    if (d->ximage && (w == d->ximage->width) && (h == d->ximage->height))
	return;

    createXImage(w, h);
    int size = d->ximage->bytes_per_line * d->ximage->height;
    if (size > d->shmsize)
	createShmSegment(size);
    d->ximage->data = d->shminfo->shmaddr;
    return;
}
    


kdelibs'KPixmapIO::doneXImage() (./kdelibs/kdeui/kpixmapio.cpp:276)

void KPixmapIO::doneXImage()
{
    if (d->shmpolicy == ShmDontKeep) {
	destroyXImage();
	destroyShmSegment();
    }
}



kdelibs'KPixmapIO::destroyXImage() (./kdelibs/kdeui/kpixmapio.cpp:285)

void KPixmapIO::destroyXImage()
{
    if (d->ximage) {
	XDestroyImage(d->ximage); 
	d->ximage = 0L;
    }
}



kdelibs'KPixmapIO::createXImage() (./kdelibs/kdeui/kpixmapio.cpp:294)

void KPixmapIO::createXImage(int w, int h)
{
    destroyXImage();
    d->ximage = XShmCreateImage(qt_xdisplay(), (Visual *) QPaintDevice::x11AppVisual(),
	    QPaintDevice::x11AppDepth(), ZPixmap, 0L, d->shminfo, w, h);
}



kdelibs'KPixmapIO::destroyShmSegment() (./kdelibs/kdeui/kpixmapio.cpp:302)

void KPixmapIO::destroyShmSegment()
{
    if (d->shmsize) {
	XShmDetach(qt_xdisplay(), d->shminfo);
	shmdt(d->shminfo->shmaddr);
	d->shmsize = 0;
    }
}



kdelibs'KPixmapIO::createShmSegment() (./kdelibs/kdeui/kpixmapio.cpp:312)

void KPixmapIO::createShmSegment(int size)
{
    destroyShmSegment();
    d->shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
    if (d->shminfo->shmid < 0) {
	kdWarning() << "" << ID << ": Could not get sysv shared memory segment" << endl;
	m_bShm = false;
	return;
    }

    d->shminfo->shmaddr = (char *) shmat(d->shminfo->shmid, 0, 0);
    if (d->shminfo->shmaddr < 0) {
	kdWarning() << "" << ID << ": Could not attach sysv shared memory segment" << endl;
	m_bShm = false;
	shmctl(d->shminfo->shmid, IPC_RMID, 0);
	return;
    }

    d->shminfo->readOnly = false;
    if (!XShmAttach(qt_xdisplay(), d->shminfo)) {
	kdWarning() << "" << ID << ": X-Server could not attach shared memory segment" << endl;
	m_bShm = false;
	shmdt(d->shminfo->shmaddr);
	shmctl(d->shminfo->shmid, IPC_RMID, 0);
	return;
    }

    d->shmsize = size;
    XSync(qt_xdisplay(), false);
    shmctl(d->shminfo->shmid, IPC_RMID, 0);
}


/*
 * The following functions convertToXImage/convertFromXImage are a little
 * long. This is because of speed, I want to get as much out of the inner
 * loop as possible.
 */


kdelibs'KPixmapIO::convertFromXImage() (./kdelibs/kdeui/kpixmapio.cpp:351)

QImage KPixmapIO::convertFromXImage()
{
    int x, y;
    int width = d->ximage->width, height = d->ximage->height;
    int bpl = d->ximage->bytes_per_line;
    char *data = d->ximage->data;

    QImage image;
    if (d->bpp == 8) {
	image.create(width, height, 8);

	// Query color map. Don't remove unused entries as a speed
	// optmization.
	int i, ncells = 256;
	XColor *cmap = new XColor[ncells];
	for (i=0; i<ncells; i++)
	    cmap[i].pixel = i;
	XQueryColors(qt_xdisplay(), QPaintDevice::x11AppColormap(),
		cmap, ncells);
	image.setNumColors(ncells);
	for (i=0; i<ncells; i++)
	    image.setColor(i, qRgb(cmap[i].red, cmap[i].green, cmap[i].blue >> 8));
    } else
	image.create(width, height, 32);

    switch (d->byteorder) {

    case bo8:
    {
	for (y=0; y<height; y++)
	    memcpy(image.scanLine(y), data + y*bpl, width);
	break;
    }

    case bo16_RGB_565: 
    case bo16_BGR_565:
    {
	Q_INT32 pixel, *src;
	QRgb *dst, val;
	for (y=0; y<height; y++) {
	    src = (Q_INT32 *) (data + y*bpl);
	    dst = (QRgb *) image.scanLine(y);
	    for (x=0; x<width/2; x++) {
		pixel = *src++;
		val = ((pixel & 0xf800) << 8) | ((pixel & 0x7e0) << 4) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
		pixel >>= 16;
		val = ((pixel & 0xf800) << 8) | ((pixel & 0x7e0) << 4) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
	    }
	    if (width%2) {
		pixel = *src++;
		val = ((pixel & 0xf800) << 8) | ((pixel & 0x7e0) << 4) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
	    }
	}
	break;
    }

    case bo16_RGB_555: 
    case bo16_BGR_555:
    {
	Q_INT32 pixel, *src;
	QRgb *dst, val;
	for (y=0; y<height; y++) {
	    src = (Q_INT32 *) (data + y*bpl);
	    dst = (QRgb *) image.scanLine(y);
	    for (x=0; x<width/2; x++) {
		pixel = *src++;
		val = ((pixel & 0x7c00) << 9) | ((pixel & 0x3e0) << 6) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
		pixel >>= 16;
		val = ((pixel & 0x7c00) << 9) | ((pixel & 0x3e0) << 6) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
	    }
	    if (width%2) {
		pixel = *src++;
		val = ((pixel & 0x7c00) << 9) | ((pixel & 0x3e0) << 6) |
			((pixel & 0x1f) << 3);
		*dst++ = val;
	    }
	}
	break;
    }

    case bo24_RGB:
    {
	char *src;
	QRgb *dst;
	int w1 = width/4;
	Q_INT32 d1, d2, d3;
	for (y=0; y<height; y++) {
	    src = data + y*bpl;
	    dst = (QRgb *) image.scanLine(y);
	    for (x=0; x<w1; x++) {
		d1 = *((Q_INT32 *)src);
		d2 = *((Q_INT32 *)src + 1);
		d3 = *((Q_INT32 *)src + 2);
		src += 12;
		*dst++ = d1;
		*dst++ = (d1 >> 24) | (d2 << 8);
		*dst++ = (d3 << 16) | (d2 >> 16);
		*dst++ = d3 >> 8;
	    }
	    for (x=w1*4; x<width; x++) {
		d1 = *src++ << 16;
		d1 += *src++ << 8;
		d1 += *src++;
		*dst++ = d1;
	    }
	}
	break;
    }

    case bo24_BGR:
    {
	char *src;
	QRgb *dst;
	int w1 = width/4;
	Q_INT32 d1, d2, d3;
	for (y=0; y<height; y++) {
	    src = data + y*bpl;
	    dst = (QRgb *) image.scanLine(y);
	    for (x=0; x<w1; x++) {
		d1 = *((Q_INT32 *)src);
		d2 = *((Q_INT32 *)src + 1);
		d3 = *((Q_INT32 *)src + 2);
		src += 12;
		*dst++ = d1;
		*dst++ = (d1 >> 24) | (d2 << 8);
		*dst++ = (d3 << 16) | (d2 >> 16);
		*dst++ = d3 >> 8;
	    }
	    for (x=w1*4; x<width; x++) {
		d1 = *src++;
		d1 += *src++ << 8;
		d1 += *src++ << 16;
		*dst++ = d1;
	    }
	}
	break;
    }

    case bo32_ARGB: 
    case bo32_BGRA:
    {
	for (y=0; y<height; y++)
	    memcpy(image.scanLine(y), data + y*bpl, width*4);
	break;
    }

    }

    return image;
}



kdelibs'KPixmapIO::convertToXImage() (./kdelibs/kdeui/kpixmapio.cpp:513)

void KPixmapIO::convertToXImage(const QImage &img)
{
    int x, y;
    int width = d->ximage->width, height = d->ximage->height;
    int bpl = d->ximage->bytes_per_line;
    char *data = d->ximage->data;

    switch (d->byteorder) {

    case bo16_RGB_555: 
    case bo16_BGR_555:

	if (img.depth() == 32) {
	    QRgb *src, pixel;
	    Q_INT32 *dst, val;
	    for (y=0; y<height; y++) {
		src = (QRgb *) img.scanLine(y);
		dst = (Q_INT32 *) (data + y*bpl);
		for (x=0; x<width/2; x++) {
		    pixel = *src++;
		    val = ((pixel & 0xf80000) >> 9) | ((pixel & 0xf800) >> 5) |
			     ((pixel & 0xff) >> 3);
		    pixel = *src++;
		    val |= (((pixel & 0xf80000) >> 9) | ((pixel & 0xf800) >> 5) |
			    ((pixel & 0xff) >> 3)) << 16;
		    *dst++ = val;
		}
		if (width%2) {
		    pixel = *src++;
		    *((Q_INT16 *)dst) = ((pixel & 0xf80000) >> 9) | 
			    ((pixel & 0xf800) >> 5) | ((pixel & 0xff) >> 3);
		}
	    }
	} else {
	    uchar *src;
	    Q_INT32 val, *dst;
	    QRgb pixel, *clut = img.colorTable();
	    for (y=0; y<height; y++) {
		src = img.scanLine(y);
		dst = (Q_INT32 *) (data + y*bpl);
		for (x=0; x<width/2; x++) {
		    pixel = clut[*src++];
		    val = ((pixel & 0xf80000) >> 9) | ((pixel & 0xf800) >> 5) |
			    ((pixel & 0xff) >> 3);
		    pixel = clut[*src++];
		    val |= (((pixel & 0xf80000) >> 9) | ((pixel & 0xf800) >> 5) |
			    ((pixel & 0xff) >> 3)) << 16;
		    *dst++ = val;
		}
		if (width%2) {
		    pixel = clut[*src++];
		    *((Q_INT16 *)dst) = ((pixel & 0xf80000) >> 9) | 
			    ((pixel & 0xf800) >> 5) | ((pixel & 0xff) >> 3);
		}
	    }
	}
	break;

    case bo16_RGB_565: 
    case bo16_BGR_565:

	if (img.depth() == 32) {
	    QRgb *src, pixel;
	    Q_INT32 *dst, val;
	    for (y=0; y<height; y++) {
		src = (QRgb *) img.scanLine(y);
		dst = (Q_INT32 *) (data + y*bpl);
		for (x=0; x<width/2; x++) {
		    pixel = *src++;
		    val = ((pixel & 0xf80000) >> 8) | ((pixel & 0xfc00) >> 5) |
			     ((pixel & 0xff) >> 3);
		    pixel = *src++;
		    val |= (((pixel & 0xf80000) >> 8) | ((pixel & 0xfc00) >> 5) |
			    ((pixel & 0xff) >> 3)) << 16;
		    *dst++ = val;
		}
		if (width%2) {
		    pixel = *src++;
		    *((Q_INT16 *)dst) = ((pixel & 0xf80000) >> 8) | 
			    ((pixel & 0xfc00) >> 5) | ((pixel & 0xff) >> 3);
		}
	    }
	} else {
	    uchar *src;
	    Q_INT32 val, *dst;
	    QRgb pixel, *clut = img.colorTable();
	    for (y=0; y<height; y++) {
		src = img.scanLine(y);
		dst = (Q_INT32 *) (data + y*bpl);
		for (x=0; x<width/2; x++) {
		    pixel = clut[*src++];
		    val = ((pixel & 0xf80000) >> 8) | ((pixel & 0xfc00) >> 5) |
			    ((pixel & 0xff) >> 3);
		    pixel = clut[*src++];
		    val |= (((pixel & 0xf80000) >> 8) | ((pixel & 0xfc00) >> 5) |
			    ((pixel & 0xff) >> 3)) << 16;
		    *dst++ = val;
		}
		if (width%2) {
		    pixel = clut[*src++];
		    *((Q_INT16 *)dst) = ((pixel & 0xf80000) >> 8) | 
			    ((pixel & 0xfc00) >> 5) | ((pixel & 0xff) >> 3);
		}
	    }
	}
	break;

    case bo24_RGB:

	if (img.depth() == 32) {
	    char *dst;
	    int w1 = width/4;
	    QRgb *src, d1, d2, d3, d4;
	    for (y=0; y<height; y++) {
		src = (QRgb *) img.scanLine(y);
		dst = data + y*bpl;
		for (x=0; x<w1; x++) {
		    d1 = (*src++ & 0xffffff); 
		    d2 = (*src++ & 0xffffff);
		    d3 = (*src++ & 0xffffff); 
		    d4 = (*src++ & 0xffffff);
		    *((Q_INT32 *)dst) = d1 | (d2 << 24);
		    *((Q_INT32 *)dst+1) = (d2 >> 8) | (d3 << 16);
		    *((Q_INT32 *)dst+2) = (d4 << 8) | (d3 >> 16);
		    dst += 12;
		}
		for (x=w1*4; x<width; x++) {
		    d1 = *src++;
		    *dst++ = qRed(d1);
		    *dst++ = qGreen(d1);
		    *dst++ = qBlue(d1);
		}
	    }
	} else {
	    uchar *src, *dst;
	    int w1 = width/4;
	    QRgb *clut = img.colorTable(), d1, d2, d3, d4;
	    for (y=0; y<height; y++) {
		src = img.scanLine(y);
		dst = (uchar *) data + y*bpl;
		for (x=0; x<w1; x++) {
		    d1 = (clut[*src++] & 0xffffff);
		    d2 = (clut[*src++] & 0xffffff);
		    d3 = (clut[*src++] & 0xffffff);
		    d4 = (clut[*src++] & 0xffffff);
		    *((Q_INT32 *)dst) = d1 | (d2 << 24);
		    *((Q_INT32 *)dst+1) = (d2 >> 8) | (d3 << 16);
		    *((Q_INT32 *)dst+2) = (d4 << 8) | (d3 >> 16);
		    dst += 12;
		}
		for (x=w1*4; x<width; x++) {
		    d1 = clut[*src++];
		    *dst++ = qRed(d1);
		    *dst++ = qGreen(d1);
		    *dst++ = qBlue(d1);
		}
	    }
	}
	break;

    case bo24_BGR:

	if (img.depth() == 32) {
	    char *dst;
	    QRgb *src, d1, d2, d3, d4;
	    int w1 = width/4;
	    for (y=0; y<height; y++) {
		src = (QRgb *) img.scanLine(y);
		dst = data + y*bpl;
		for (x=0; x<w1; x++) {
		    d1 = (*src++ & 0xffffff); 
		    d2 = (*src++ & 0xffffff);
		    d3 = (*src++ & 0xffffff); 
		    d4 = (*src++ & 0xffffff);
		    *((Q_INT32 *)dst) = d1 | (d2 << 24);
		    *((Q_INT32 *)dst+1) = (d2 >> 8) | (d3 << 16);
		    *((Q_INT32 *)dst+2) = (d4 << 8) | (d3 >> 16);
		    dst += 12;
		}
		for (x=w1*4; x<width; x++) {
		    d1 = *src++;
		    *dst++ = qBlue(d1);
		    *dst++ = qGreen(d1);
		    *dst++ = qRed(d1);
		}
	    }
	} else {
	    uchar *src, *dst;
	    int w1 = width/4;
	    QRgb *clut = img.colorTable(), d1, d2, d3, d4;
	    for (y=0; y<height; y++) {
		src = img.scanLine(y);
		dst = (uchar *) data + y*bpl;
		for (x=0; x<w1; x++) {
		    d1 = (clut[*src++] & 0xffffff);
		    d2 = (clut[*src++] & 0xffffff);
		    d3 = (clut[*src++] & 0xffffff);
		    d4 = (clut[*src++] & 0xffffff);
		    *((Q_INT32 *)dst) = d1 | (d2 << 24);
		    *((Q_INT32 *)dst+1) = (d2 >> 8) | (d3 << 16);
		    *((Q_INT32 *)dst+2) = (d4 << 8) | (d3 >> 16);
		    dst += 12;
		}
		for (x=w1*4; x<width; x++) {
		    d1 = clut[*src++];
		    *dst++ = qBlue(d1);
		    *dst++ = qGreen(d1);
		    *dst++ = qRed(d1);
		}
	    }
	}
	break;

    case bo32_ARGB: 
    case bo32_BGRA:

	if (img.depth() == 32) {
	    for (y=0; y<height; y++)
		memcpy(data + y*bpl, img.scanLine(y), width*4);
	} else {
	    uchar *src;
	    QRgb *dst, *clut = img.colorTable();
	    for (y=0; y<height; y++) {
		src = img.scanLine(y);
		dst = (QRgb *) (data + y*bpl);
		for (x=0; x<width; x++)
		    *dst++ = clut[*src++];
	    }
	}
	break;

    }
}

kdelibs'KPixmapIO::preAllocShm() (./kdelibs/kdeui/kpixmapio.cpp:749)

void KPixmapIO::preAllocShm(int) {}

kdelibs'KPixmapIO::setShmPolicy() (./kdelibs/kdeui/kpixmapio.cpp:750)

void KPixmapIO::setShmPolicy(int) {}

kdelibs'KPixmapIO::initXImage() (./kdelibs/kdeui/kpixmapio.cpp:751)

void KPixmapIO::initXImage(int, int) {}

kdelibs'KPixmapIO::doneXImage() (./kdelibs/kdeui/kpixmapio.cpp:752)

void KPixmapIO::doneXImage() {}

kdelibs'KPixmapIO::createXImage() (./kdelibs/kdeui/kpixmapio.cpp:753)

void KPixmapIO::createXImage(int, int) {}

kdelibs'KPixmapIO::destroyXImage() (./kdelibs/kdeui/kpixmapio.cpp:754)

void KPixmapIO::destroyXImage() {}

kdelibs'KPixmapIO::createShmSegment() (./kdelibs/kdeui/kpixmapio.cpp:755)

void KPixmapIO::createShmSegment(int) {}

kdelibs'KPixmapIO::destroyShmSegment() (./kdelibs/kdeui/kpixmapio.cpp:756)

void KPixmapIO::destroyShmSegment() {}

kdelibs'KPixmapIO::convertFromXImage() (./kdelibs/kdeui/kpixmapio.cpp:757)

QImage KPixmapIO::convertFromXImage() { return QImage(); }

kdelibs'KPixmapIO::convertToXImage() (./kdelibs/kdeui/kpixmapio.cpp:758)

void KPixmapIO::convertToXImage(const QImage &) {}