QImageData Struct Reference

Collaboration diagram for QImageData:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 82 of file qimage.cpp.

Public Member Functions

 QImageData ()
 ~QImageData ()
QStringList languages () const
QStringList keys () const
bool doImageIO (const QImage *image, QImageWriter *io, int quality) const

Static Public Member Functions

static QImageDatacreate (const QSize &size, QImage::Format format, int numColors=0)

Public Attributes

QAtomic ref
int width
int height
int depth
int nbytes
QVector< QRgbcolortable
uchar * data
QImage::Format format
int bytes_per_line
int ser_no
int detach_no
qreal dpmx
qreal dpmy
QPoint offset
uint own_data: 1
uint ro_data: 1
uint has_alpha_clut: 1
QMap< QImageTextKeyLang, QStringtext_lang
QMap< QString, QStringtext
QPaintEnginepaintEngine


Constructor & Destructor Documentation

QImageData::QImageData (  ) 

Definition at line 168 of file qimage.cpp.

References bytes_per_line, data, depth, detach_no, dpmx, dpmy, QImage::Format_ARGB32, has_alpha_clut, height, nbytes, offset, own_data, paintEngine, qimage_next_serial_number(), qt_defaultDpi(), ref, ro_data, ser_no, and width.

00169 {
00170     ser_no = qimage_next_serial_number();
00171     detach_no = 0;
00172     ref = 0;
00173 
00174     width = height = depth = 0;
00175     nbytes = 0;
00176     data = 0;
00177     own_data = true;
00178     ro_data = false;
00179     has_alpha_clut = false;
00180 #ifdef QT3_SUPPORT
00181     jumptable = 0;
00182 #endif
00183     bytes_per_line = 0;
00184     format = QImage::Format_ARGB32;
00185 
00186     dpmx = qt_defaultDpi()*100./2.54;
00187     dpmy = qt_defaultDpi()*100./2.54;
00188     offset = QPoint(0,0);
00189 
00190     paintEngine = 0;
00191 }

Here is the call graph for this function:

QImageData::~QImageData (  ) 

Definition at line 293 of file qimage.cpp.

References data, own_data, paintEngine, qt_image_cleanup_hook, and ser_no.

00294 {
00295     if (qt_image_cleanup_hook)
00296         qt_image_cleanup_hook(ser_no);
00297     delete paintEngine;
00298     if (data && own_data)
00299         free(data);
00300 #ifdef QT3_SUPPORT
00301     if (jumptable)
00302         free(jumptable);
00303     jumptable = 0;
00304 #endif
00305     data = 0;
00306 }


Member Function Documentation

QImageData * QImageData::create ( const QSize size,
QImage::Format  format,
int  numColors = 0 
) [static]

Definition at line 219 of file qimage.cpp.

References Qt::black, bytes_per_line, d, depth, QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Indexed8, QImage::Format_Invalid, QImage::Format_Mono, QImage::Format_MonoLSB, QImage::Format_RGB16, QImage::Format_RGB32, height, i, QImage::NImageFormats, qMax(), qMin(), size, Qt::white, and width.

Referenced by convert_ARGB_PM_to_Indexed8(), convert_ARGB_PM_to_Mono(), and QImage::QImage().

00220 {
00221     if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
00222         return 0;                                // invalid parameter(s)
00223     uint width = size.width();
00224     uint height = size.height();
00225 
00226     uint depth = 0;
00227     switch(format) {
00228     case QImage::NImageFormats:
00229     case QImage::Format_Invalid:
00230         Q_ASSERT(false);
00231     case QImage::Format_Mono:
00232     case QImage::Format_MonoLSB:
00233         depth = 1;
00234         numColors = 2;
00235         break;
00236     case QImage::Format_Indexed8:
00237         depth = 8;
00238         numColors = qMin(numColors, 256);
00239         numColors = qMax(0, numColors);
00240         break;
00241     case QImage::Format_RGB32:
00242     case QImage::Format_ARGB32:
00243     case QImage::Format_ARGB32_Premultiplied:
00244         depth = 32;
00245         numColors = 0;
00246         break;
00247     case QImage::Format_RGB16:
00248         depth = 16;
00249         numColors = 0;
00250         break;
00251     }
00252 
00253     const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 8)
00254 
00255     // sanity check for potential overflows
00256     if (INT_MAX/depth < width
00257         || bytes_per_line <= 0
00258         || INT_MAX/uint(bytes_per_line) < height
00259         || INT_MAX/sizeof(uchar *) < uint(height))
00260         return 0;
00261 
00262     QImageData *d = new QImageData;
00263     d->colortable.resize(numColors);
00264     if (depth == 1) {
00265         d->colortable[0] = QColor(Qt::black).rgba();
00266         d->colortable[1] = QColor(Qt::white).rgba();
00267     } else {
00268         for (int i = 0; i < numColors; ++i)
00269             d->colortable[i] = 0;
00270     }
00271 
00272     d->width = width;
00273     d->height = height;
00274     d->depth = depth;
00275     d->format = format;
00276     d->has_alpha_clut = false;
00277 
00278     d->bytes_per_line = bytes_per_line;
00279 
00280     d->nbytes = d->bytes_per_line*height;
00281     d->data  = (uchar *)malloc(d->nbytes);
00282 
00283     if (!d->data) {
00284         delete d;
00285         return 0;
00286     }
00287 
00288     d->ref.ref();
00289     return d;
00290 
00291 }

Here is the call graph for this function:

QStringList QImageData::languages (  )  const [inline]

Definition at line 113 of file qimage.cpp.

References QList< T >::append(), QMap< Key, T >::begin(), QByteArray::constData(), QMap< Key, T >::end(), QString::fromAscii(), QMap< Key, T >::key(), QImageTextKeyLang::lang, QList< T >::removeAll(), and text_lang.

00114     {
00115         QStringList r;
00116         QMap<QImageTextKeyLang,QString>::const_iterator it = text_lang.begin();
00117         for (; it != text_lang.end(); ++it) {
00118             QString lang = QString::fromAscii(it.key().lang.constData());
00119             r.removeAll(lang);
00120             r.append(lang);
00121         }
00122         return r;
00123     }

Here is the call graph for this function:

QStringList QImageData::keys (  )  const [inline]

Definition at line 124 of file qimage.cpp.

References QList< T >::append(), QMap< Key, T >::begin(), QByteArray::constData(), QMap< Key, T >::end(), QString::fromAscii(), QImageTextKeyLang::key, key, QMap< Key, T >::key(), QList< T >::removeAll(), and text_lang.

00125     {
00126         QStringList r;
00127         QMap<QImageTextKeyLang,QString>::const_iterator it = text_lang.begin();
00128         for (; it != text_lang.end(); ++it) {
00129             QString key = QString::fromAscii(it.key().key.constData());
00130             r.removeAll(key);
00131             r.append(key);
00132         }
00133         return r;
00134     }

Here is the call graph for this function:

bool QImageData::doImageIO ( const QImage image,
QImageWriter io,
int  quality 
) const

Definition at line 4231 of file qimage.cpp.

References image, qMin(), qWarning(), QImageWriter::setQuality(), and QImageWriter::write().

Referenced by QImage::save().

04232 {
04233     if (quality > 100  || quality < -1)
04234         qWarning("QPixmap::save: Quality out of range [-1, 100]");
04235     if (quality >= 0)
04236         writer->setQuality(qMin(quality,100));
04237     return writer->write(*image);
04238 }

Here is the call graph for this function:


Member Data Documentation

QAtomic QImageData::ref

Definition at line 87 of file qimage.cpp.

Referenced by QImage::detach(), QImage::QImage(), QImageData(), and QImage::~QImage().

int QImageData::width

Definition at line 89 of file qimage.cpp.

Referenced by convert_16_to_32(), convert_32_to_16(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_Indexed8(), convert_ARGB_PM_to_Mono(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::convertToFormat(), QImage::copy(), create(), QImage::createAlphaMask(), dither_to_Mono(), QImage::invertPixels(), mask_alpha_converter(), QImage::mirrored(), QImage::pixel(), QImage::pixelIndex(), QImage::QImage(), QImageData(), QImage::rect(), QImage::rgbSwapped(), QImage::setAlphaChannel(), QImage::size(), swap_bit_order(), QImage::valid(), and QImage::width().

int QImageData::height

Definition at line 90 of file qimage.cpp.

Referenced by QImage::bytesPerLine(), convert_16_to_32(), convert_32_to_16(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_Indexed8(), convert_ARGB_PM_to_Mono(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::convertToFormat(), QImage::copy(), create(), QImage::createAlphaMask(), dither_to_Mono(), QImage::height(), QImage::invertPixels(), mask_alpha_converter(), QImage::mirrored(), QImage::QImage(), QImageData(), QImage::rect(), QImage::rgbSwapped(), QImage::setAlphaChannel(), QImage::size(), swap_bit_order(), and QImage::valid().

int QImageData::depth

Definition at line 91 of file qimage.cpp.

Referenced by QImage::allGray(), QImage::copy(), create(), QImage::createAlphaMask(), QImage::createHeuristicMask(), QImage::depth(), dither_to_Mono(), QImage::fill(), QImage::invertPixels(), QImage::mirrored(), QImage::pixelIndex(), QImage::QImage(), QImageData(), and QImage::setAlphaChannel().

int QImageData::nbytes

Definition at line 92 of file qimage.cpp.

Referenced by QImage::bytesPerLine(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), QImage::copy(), dither_to_Mono(), QImage::fill(), QImage::invertPixels(), mask_alpha_converter(), QImage::numBytes(), QImage::QImage(), QImageData(), and swap_bit_order().

QVector<QRgb> QImageData::colortable

Definition at line 93 of file qimage.cpp.

Referenced by QImage::allGray(), QImage::color(), QImage::colorTable(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::copy(), dither_to_Mono(), QImage::isGrayscale(), QImage::mirrored(), QImage::numColors(), QImage::pixel(), QImage::rgbSwapped(), QImage::setColor(), QImage::setColorTable(), QImage::setNumColors(), QImage::setPixel(), swap_bit_order(), and QImage::transformed().

uchar* QImageData::data

Definition at line 94 of file qimage.cpp.

Referenced by QImage::bits(), convert_16_to_32(), convert_32_to_16(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::copy(), dither_to_Mono(), QImage::fill(), QImage::invertPixels(), mask_alpha_converter(), QImage::mirrored(), QImage::QImage(), QImageData(), QImage::scanLine(), QImage::setAlphaChannel(), swap_bit_order(), and ~QImageData().

QImage::Format QImageData::format

Definition at line 98 of file qimage.cpp.

Referenced by convert_16_to_32(), convert_32_to_16(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::convertToFormat(), QImage::copy(), QImage::createAlphaMask(), dither_to_Mono(), QImage::fill(), QImage::format(), QImage::mirrored(), QImage::pixel(), QImage::pixelIndex(), QImage::QImage(), QImage::rgbSwapped(), QImage::setPixel(), swap_bit_order(), and QImage::transformed().

int QImageData::bytes_per_line

Definition at line 99 of file qimage.cpp.

Referenced by convert_16_to_32(), convert_32_to_16(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_Indexed8_to_X32(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), QImage::copy(), create(), dither_to_Mono(), QImage::invertPixels(), QImage::mirrored(), QImage::QImage(), QImageData(), QImage::scanLine(), QImage::setAlphaChannel(), and swap_bit_order().

int QImageData::ser_no

Definition at line 100 of file qimage.cpp.

Referenced by QImageData(), and ~QImageData().

int QImageData::detach_no

Definition at line 101 of file qimage.cpp.

Referenced by QImage::detach(), and QImageData().

qreal QImageData::dpmx

Definition at line 103 of file qimage.cpp.

Referenced by QImage::copy(), QImageData(), and QImage::transformed().

qreal QImageData::dpmy

Definition at line 104 of file qimage.cpp.

Referenced by QImage::copy(), QImageData(), and QImage::transformed().

QPoint QImageData::offset

Definition at line 105 of file qimage.cpp.

Referenced by QImage::copy(), and QImageData().

uint QImageData::own_data

Definition at line 106 of file qimage.cpp.

Referenced by QImage::QImage(), QImageData(), and ~QImageData().

uint QImageData::ro_data

Definition at line 107 of file qimage.cpp.

Referenced by QImage::detach(), QImage::QImage(), and QImageData().

uint QImageData::has_alpha_clut

Definition at line 108 of file qimage.cpp.

Referenced by QImage::copy(), QImageData(), QImage::setColor(), QImage::setColorTable(), and QImage::transformed().

QMap<QImageTextKeyLang, QString> QImageData::text_lang

Definition at line 111 of file qimage.cpp.

Referenced by QImage::convertToFormat(), QImage::copy(), keys(), and languages().

QMap<QString, QString> QImageData::text

Definition at line 136 of file qimage.cpp.

Referenced by QImage::convertToFormat().

QPaintEngine* QImageData::paintEngine

Definition at line 140 of file qimage.cpp.

Referenced by QImageData(), and ~QImageData().


The documentation for this struct was generated from the following file:
Generated on Thu Mar 15 18:02:39 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1