src/gui/image/qpixmap_x11.cpp File Reference

#include "qplatformdefs.h"
#include "qdebug.h"
#include "qiodevice.h"
#include "qpixmap_p.h"
#include "qbitmap.h"
#include "qcolormap.h"
#include "qimage.h"
#include "qmatrix.h"
#include "qapplication.h"
#include <private/qpaintengine_x11_p.h>
#include <private/qt_x11_p.h>
#include "qx11info_x11.h"
#include <private/qdrawhelper_p.h>
#include <stdlib.h>

Include dependency graph for qpixmap_x11.cpp:

Go to the source code of this file.

Defines

#define GET_PIXEL
#define GET_PIXEL_DITHER_TC
#define GET_PIXEL_DITHER_TC_OPT(red_shift, green_shift, blue_shift, red_mask, green_mask, blue_mask, rbits, gbits, bbits)
#define CYCLE(body)

Functions

static void qSafeXDestroyImage (XImage *x)
const uchar * qt_get_bitflip_array ()
static int highest_bit (uint v)
static int lowest_bit (uint v)
static uint n_bits (uint v)
static void cleanup_scale_tables ()
static void build_scale_table (uint **table, uint nBits)

Variables

static uint * red_scale_table = 0
static uint * green_scale_table = 0
static uint * blue_scale_table = 0
static int defaultScreen = -1
static int qt_pixmap_serial = 0
int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0


Define Documentation

#define CYCLE ( body   ) 

Value:

for (int y=0; y<h; y++) {                               \
            const uchar* src = cimage.scanLine(y);              \
            uchar* dst = newbits + xi->bytes_per_line*y;        \
            const QRgb* p = (const QRgb *)src;                  \
            body                                                \
                }

#define GET_PIXEL

Value:

uint pixel;                                                     \
        if (d8) pixel = pix[*src++];                                    \
        else {                                                          \
            int r = qRed  (*p);                                         \
            int g = qGreen(*p);                                         \
            int b = qBlue (*p++);                                       \
            r = red_shift   > 0                                         \
                ? r << red_shift   : r >> -red_shift;                   \
            g = green_shift > 0                                         \
                ? g << green_shift : g >> -green_shift;                 \
            b = blue_shift  > 0                                         \
                ? b << blue_shift  : b >> -blue_shift;                  \
            pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask)   \
                    | ~(blue_mask | green_mask | red_mask);             \
        }

#define GET_PIXEL_DITHER_TC

Value:

int r = qRed  (*p);                                             \
        int g = qGreen(*p);                                             \
        int b = qBlue (*p++);                                           \
        const int thres = D[x%16][y%16];                                \
        if (r <= (255-(1<<(8-rbits))) && ((r<<rbits) & 255)             \
            > thres)                                                    \
            r += (1<<(8-rbits));                                        \
        if (g <= (255-(1<<(8-gbits))) && ((g<<gbits) & 255)             \
            > thres)                                                    \
            g += (1<<(8-gbits));                                        \
        if (b <= (255-(1<<(8-bbits))) && ((b<<bbits) & 255)             \
            > thres)                                                    \
            b += (1<<(8-bbits));                                        \
        r = red_shift   > 0                                             \
            ? r << red_shift   : r >> -red_shift;                       \
        g = green_shift > 0                                             \
            ? g << green_shift : g >> -green_shift;                     \
        b = blue_shift  > 0                                             \
            ? b << blue_shift  : b >> -blue_shift;                      \
        uint pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask);

#define GET_PIXEL_DITHER_TC_OPT ( red_shift,
green_shift,
blue_shift,
red_mask,
green_mask,
blue_mask,
rbits,
gbits,
bbits   ) 

Value:

const int thres = D[x%16][y%16];                                \
        int r = qRed  (*p);                                             \
        if (r <= (255-(1<<(8-rbits))) && ((r<<rbits) & 255)             \
            > thres)                                                    \
            r += (1<<(8-rbits));                                        \
        int g = qGreen(*p);                                             \
        if (g <= (255-(1<<(8-gbits))) && ((g<<gbits) & 255)             \
            > thres)                                                    \
            g += (1<<(8-gbits));                                        \
        int b = qBlue (*p++);                                           \
        if (b <= (255-(1<<(8-bbits))) && ((b<<bbits) & 255)             \
            > thres)                                                    \
            b += (1<<(8-bbits));                                        \
        uint pixel = ((r red_shift) & red_mask)                         \
                     | ((g green_shift) & green_mask)                   \
                     | ((b blue_shift) & blue_mask);


Function Documentation

static void build_scale_table ( uint **  table,
uint  nBits 
) [static]

Definition at line 238 of file qpixmap_x11.cpp.

References cleanup_scale_tables(), i, QCoreApplication::qAddPostRoutine(), and qWarning().

00239 {
00240     if (nBits > 7) {
00241         qWarning("build_scale_table: internal error, nBits = %i", nBits);
00242         return;
00243     }
00244     if (!*table) {
00245         static bool firstTable = true;
00246         if (firstTable) {
00247             qAddPostRoutine(cleanup_scale_tables);
00248             firstTable = false;
00249         }
00250         *table = new uint[256];
00251     }
00252     int   maxVal   = (1 << nBits) - 1;
00253     int   valShift = 8 - nBits;
00254     int i;
00255     for(i = 0 ; i < maxVal + 1 ; i++)
00256         (*table)[i << valShift] = i*255/maxVal;
00257 }

Here is the call graph for this function:

static void cleanup_scale_tables (  )  [static]

Definition at line 227 of file qpixmap_x11.cpp.

Referenced by build_scale_table().

00228 {
00229     delete[] red_scale_table;
00230     delete[] green_scale_table;
00231     delete[] blue_scale_table;
00232 }

static int highest_bit ( uint  v  )  [static]

Definition at line 193 of file qpixmap_x11.cpp.

References b, and i.

00194 {
00195     int i;
00196     uint b = (uint)1 << 31;
00197     for (i=31; ((b & v) == 0) && i>=0;         i--)
00198         b >>= 1;
00199     return i;
00200 }

static int lowest_bit ( uint  v  )  [static]

Definition at line 203 of file qpixmap_x11.cpp.

References i.

Referenced by QColormap::initialize().

00204 {
00205     int i;
00206     ulong lb;
00207     lb = 1;
00208     for (i=0; ((v & lb) == 0) && i<32;  i++, lb<<=1);
00209     return i==32 ? -1 : i;
00210 }

static uint n_bits ( uint  v  )  [static]

Definition at line 213 of file qpixmap_x11.cpp.

References i.

00214 {
00215     int i = 0;
00216     while (v) {
00217         v = v & (v - 1);
00218         i++;
00219     }
00220     return i;
00221 }

static void qSafeXDestroyImage ( XImage *  x  )  [inline, static]

Definition at line 62 of file qpixmap_x11.cpp.

00063 {
00064     if (x->data) {
00065         free(x->data);
00066         x->data = 0;
00067     }
00068     XDestroyImage(x);
00069 }

const uchar* qt_get_bitflip_array (  ) 

Definition at line 733 of file qimage.cpp.

References bitflip.

00734 {
00735     return bitflip;
00736 }


Variable Documentation

uint* blue_scale_table = 0 [static]

Definition at line 225 of file qpixmap_x11.cpp.

int defaultScreen = -1 [static]

Definition at line 259 of file qpixmap_x11.cpp.

uint* green_scale_table = 0 [static]

Definition at line 224 of file qpixmap_x11.cpp.

int qt_pixmap_serial = 0 [static]

Definition at line 265 of file qpixmap_x11.cpp.

int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0

Definition at line 266 of file qpixmap_x11.cpp.

Referenced by QGLWidget::renderPixmap().

uint* red_scale_table = 0 [static]

Definition at line 223 of file qpixmap_x11.cpp.


Generated on Thu Mar 15 13:20:32 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1