172 |
172 |
173 #ifdef QT_DIRECTFB_IMAGEPROVIDER |
173 #ifdef QT_DIRECTFB_IMAGEPROVIDER |
174 bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format, |
174 bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format, |
175 Qt::ImageConversionFlags flags) |
175 Qt::ImageConversionFlags flags) |
176 { |
176 { |
|
177 if (!QFile::exists(filename)) |
|
178 return false; |
177 if (flags == Qt::AutoColor) { |
179 if (flags == Qt::AutoColor) { |
178 if (filename.startsWith(QLatin1Char(':'))) { // resource |
180 if (filename.startsWith(QLatin1Char(':'))) { // resource |
179 QFile file(filename); |
181 QFile file(filename); |
180 if (!file.open(QIODevice::ReadOnly)) |
182 if (!file.open(QIODevice::ReadOnly)) |
181 return false; |
183 return false; |
286 #endif |
288 #endif |
287 |
289 |
288 void QDirectFBPixmapData::fromImage(const QImage &img, |
290 void QDirectFBPixmapData::fromImage(const QImage &img, |
289 Qt::ImageConversionFlags flags) |
291 Qt::ImageConversionFlags flags) |
290 { |
292 { |
291 if (img.depth() == 1 || img.format() == QImage::Format_RGB32) { |
293 if (img.depth() == 1) { |
292 fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); |
294 alpha = true; |
293 return; |
|
294 } |
|
295 |
|
296 if (img.hasAlphaChannel() |
|
297 #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION |
295 #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION |
298 && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) |
296 } else if (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) { |
299 #endif |
|
300 ) { |
|
301 alpha = true; |
297 alpha = true; |
302 imageFormat = screen->alphaPixmapFormat(); |
298 #else |
303 } else { |
299 } else if (img.hasAlphaChannel()) { |
304 alpha = false; |
300 alpha = true; |
305 imageFormat = screen->pixelFormat(); |
301 #endif |
306 } |
302 } |
|
303 imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat(); |
307 QImage image; |
304 QImage image; |
308 if (flags != Qt::AutoColor) { |
305 if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) { |
309 image = img.convertToFormat(imageFormat, flags); |
306 image = img.convertToFormat(imageFormat, flags); |
310 flags = Qt::AutoColor; |
307 flags = Qt::AutoColor; |
311 } else if (img.format() == QImage::Format_RGB32) { |
308 } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) { |
312 image = img.convertToFormat(imageFormat, flags); |
309 image = img.convertToFormat(imageFormat, flags); |
313 } else { |
310 } else { |
314 image = img; |
311 image = img; |
315 } |
312 } |
316 |
313 |
423 if (!serialNumber()) |
420 if (!serialNumber()) |
424 return; |
421 return; |
425 |
422 |
426 Q_ASSERT(dfbSurface); |
423 Q_ASSERT(dfbSurface); |
427 |
424 |
428 alpha = (color.alpha() < 255); |
425 alpha |= (color.alpha() < 255); |
429 |
426 |
430 if (alpha && isOpaqueFormat(imageFormat)) { |
427 if (alpha && isOpaqueFormat(imageFormat)) { |
431 QSize size; |
428 QSize size; |
432 dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); |
429 dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); |
433 screen->releaseDFBSurface(dfbSurface); |
430 screen->releaseDFBSurface(dfbSurface); |
591 d = w = h = 0; |
588 d = w = h = 0; |
592 is_null = true; |
589 is_null = true; |
593 imageFormat = QImage::Format_Invalid; |
590 imageFormat = QImage::Format_Invalid; |
594 } |
591 } |
595 |
592 |
|
593 #ifndef QT_DIRECTFB_PLUGIN |
|
594 Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_pixmap(const QPixmap &pixmap) |
|
595 { |
|
596 const QPixmapData *data = pixmap.pixmapData(); |
|
597 if (!data || data->classId() != QPixmapData::DirectFBClass) |
|
598 return 0; |
|
599 const QDirectFBPixmapData *dfbData = static_cast<const QDirectFBPixmapData*>(data); |
|
600 return dfbData->directFBSurface(); |
|
601 } |
|
602 #endif |
|
603 |
596 QT_END_NAMESPACE |
604 QT_END_NAMESPACE |
597 |
605 |
598 #endif // QT_NO_QWS_DIRECTFB |
606 #endif // QT_NO_QWS_DIRECTFB |