src/gui/image/qpixmapdata.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    48 
    48 
    49 QT_BEGIN_NAMESPACE
    49 QT_BEGIN_NAMESPACE
    50 
    50 
    51 const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
    51 const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
    52                                      0x10, 0x20, 0x40, 0x80 };
    52                                      0x10, 0x20, 0x40, 0x80 };
       
    53 
       
    54 QPixmapData *QPixmapData::create(int w, int h, PixelType type)
       
    55 {
       
    56     QPixmapData *data;
       
    57     QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
       
    58     if (gs)
       
    59         data = gs->createPixmapData(static_cast<QPixmapData::PixelType>(type));
       
    60     else
       
    61         data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type));
       
    62     data->resize(w, h);
       
    63     return data;
       
    64 }
       
    65 
    53 
    66 
    54 QPixmapData::QPixmapData(PixelType pixelType, int objectId)
    67 QPixmapData::QPixmapData(PixelType pixelType, int objectId)
    55     : w(0),
    68     : w(0),
    56       h(0),
    69       h(0),
    57       d(0),
    70       d(0),
   186 
   199 
   187     QImage mask(w, h, QImage::Format_MonoLSB);
   200     QImage mask(w, h, QImage::Format_MonoLSB);
   188     if (mask.isNull()) // allocation failed
   201     if (mask.isNull()) // allocation failed
   189         return QBitmap();
   202         return QBitmap();
   190 
   203 
   191     mask.setNumColors(2);
   204     mask.setColorCount(2);
   192     mask.setColor(0, QColor(Qt::color0).rgba());
   205     mask.setColor(0, QColor(Qt::color0).rgba());
   193     mask.setColor(1, QColor(Qt::color1).rgba());
   206     mask.setColor(1, QColor(Qt::color1).rgba());
   194 
   207 
   195     const int bpl = mask.bytesPerLine();
   208     const int bpl = mask.bytesPerLine();
   196 
   209