src/gui/image/qpixmap.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   829         QString::number(info.size()) + QLatin1Char('_') + QString::number(data ? data->pixelType() : QPixmapData::PixmapType);
   829         QString::number(info.size()) + QLatin1Char('_') + QString::number(data ? data->pixelType() : QPixmapData::PixmapType);
   830 
   830 
   831     if (QPixmapCache::find(key, *this))
   831     if (QPixmapCache::find(key, *this))
   832         return true;
   832         return true;
   833 
   833 
   834     bool ok;
   834     QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, data ? data->type : QPixmapData::PixmapType));
   835 
   835     if (tmp->fromFile(fileName, format, flags)) {
   836     if (data) {
   836         data = tmp.take();
   837         ok = data->fromFile(fileName, format, flags);
       
   838     } else {
       
   839         QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, QPixmapData::PixmapType));
       
   840         ok = tmp->fromFile(fileName, format, flags);
       
   841         if (ok)
       
   842             data = tmp.take();
       
   843     }
       
   844 
       
   845     if (ok)
       
   846         QPixmapCache::insert(key, *this);
   837         QPixmapCache::insert(key, *this);
   847 
   838         return true;
   848     return ok;
   839     }
       
   840 
       
   841     return false;
   849 }
   842 }
   850 
   843 
   851 /*!
   844 /*!
   852     \fn bool QPixmap::loadFromData(const uchar *data, uint len, const char *format, Qt::ImageConversionFlags flags)
   845     \fn bool QPixmap::loadFromData(const uchar *data, uint len, const char *format, Qt::ImageConversionFlags flags)
   853 
   846 
  2024     The grabWindow() function grabs pixels from the screen, not from
  2017     The grabWindow() function grabs pixels from the screen, not from
  2025     the window, i.e. if there is another window partially or entirely
  2018     the window, i.e. if there is another window partially or entirely
  2026     over the one you grab, you get pixels from the overlying window,
  2019     over the one you grab, you get pixels from the overlying window,
  2027     too. The mouse cursor is generally not grabbed.
  2020     too. The mouse cursor is generally not grabbed.
  2028 
  2021 
  2029     Note on X11that if the given \a window doesn't have the same depth
  2022     Note on X11 that if the given \a window doesn't have the same depth
  2030     as the root window, and another window partially or entirely
  2023     as the root window, and another window partially or entirely
  2031     obscures the one you grab, you will \e not get pixels from the
  2024     obscures the one you grab, you will \e not get pixels from the
  2032     overlying window.  The contents of the obscured areas in the
  2025     overlying window.  The contents of the obscured areas in the
  2033     pixmap will be undefined and uninitialized.
  2026     pixmap will be undefined and uninitialized.
  2034 
  2027 
       
  2028     On Windows Vista and above grabbing a layered window, which is
       
  2029     created by setting the Qt::WA_TranslucentBackground attribute, will
       
  2030     not work. Instead grabbing the desktop widget should work.
       
  2031 
  2035     \warning In general, grabbing an area outside the screen is not
  2032     \warning In general, grabbing an area outside the screen is not
  2036     safe. This depends on the underlying window system.
  2033     safe. This depends on the underlying window system.
  2037 
  2034 
  2038     \sa grabWidget(), {Screenshot Example}
  2035     \sa grabWidget(), {Screenshot Example}
  2039 */
  2036 */