44 #ifndef QT_NO_QWS_DIRECTFB 49 #include <QtGui/qbitmap.h> 50 #include <QtCore/qfile.h> 71 if (width <= 0 || height <= 0) {
84 qWarning(
"QDirectFBPixmapData::resize(): Unable to allocate surface");
94 #ifdef QT_DIRECTFB_OPAQUE_DETECTION 100 const uchar *end_bits = bits + bytes_per_line;
108 for (
int y=0; y<
height; ++y) {
109 for (
int x=0; x<
width; ++x) {
110 if ((((
uint *)bits)[x] & 0xff000000) != 0xff000000) {
114 bits += bytes_per_line;
120 for (
int y=0; y<
height; ++y) {
121 while (bits < end_bits) {
128 end_bits += bytes_per_line;
133 for (
int y=0; y<
height; ++y) {
134 while (bits < end_bits) {
135 if ((bits[0] & 0xfc) != 0) {
141 end_bits += bytes_per_line;
146 for (
int y=0; y<
height; ++y) {
147 while (bits < end_bits) {
148 if ((bits[0] & 0xf0) != 0) {
154 end_bits += bytes_per_line;
164 #endif // QT_DIRECTFB_OPAQUE_DETECTION 168 if (img.
depth() == 1)
170 #ifdef QT_DIRECTFB_OPAQUE_DETECTION 178 #ifdef QT_DIRECTFB_IMAGEPROVIDER 180 Qt::ImageConversionFlags flags)
186 QFile file(filename);
193 DFBDataBufferDescription description;
194 description.flags = DBDESC_FILE;
196 description.file = fileNameData.
constData();
207 Qt::ImageConversionFlags flags)
210 DFBDataBufferDescription description;
211 description.flags = DBDESC_MEMORY;
212 description.memory.data =
buffer;
213 description.memory.length = len;
223 static void cleanup(T *t) {
if (t) t->Release(t); }
226 template <
typename T>
239 DFBResult result = DFB_OK;
240 IDirectFBDataBuffer *dataBufferPtr;
241 if ((result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, &dataBufferPtr)) != DFB_OK) {
242 DirectFBError(
"QDirectFBPixmapData::fromDataBufferDescription()", result);
247 IDirectFBImageProvider *providerPtr;
248 if ((result = dataBuffer->CreateImageProvider(dataBuffer.
data(), &providerPtr)) != DFB_OK)
253 DFBImageDescription imageDescription;
254 result = provider->GetImageDescription(provider.
data(), &imageDescription);
255 if (result != DFB_OK) {
256 DirectFBError(
"QDirectFBPixmapData::fromSurfaceDescription(): Can't get image description", result);
260 if (imageDescription.caps & DICAPS_COLORKEY) {
264 DFBSurfaceDescription surfaceDescription;
265 if ((result = provider->GetSurfaceDescription(provider.
data(), &surfaceDescription)) != DFB_OK) {
266 DirectFBError(
"QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result);
270 alpha = imageDescription.caps & DICAPS_ALPHACHANNEL;
277 if (result != DFB_OK) {
278 DirectFBError(
"QDirectFBPixmapData::fromSurfaceDescription(): Can't render to surface", result);
282 w = surfaceDescription.width;
283 h = surfaceDescription.height;
288 #if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE 289 screen->setDirectFBImageProvider(providerPtr);
317 qWarning(
"QDirectFBPixmapData::fromImage()");
327 #ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION 340 #ifdef QT_NO_DIRECTFB_SUBSURFACE 355 qWarning(
"QDirectFBPixmapData::copy()");
366 const DFBRectangle blitRect = { rect.
x(), rect.
y(),
374 #if (Q_DIRECTFB_VERSION >= 0x010000) 377 if (result != DFB_OK) {
378 DirectFBError(
"QDirectFBPixmapData::copy()", result);
420 qWarning(
"QDirectFBPixmapData::fill()");
433 #ifdef QT_NO_DIRECTFB_SUBSURFACE 455 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
458 flags = DSBLIT_BLEND_ALPHACHANNEL;
463 if (flags & DSBLIT_BLEND_ALPHACHANNEL) {
468 const DFBRectangle destRect = { 0, 0, size.
width(), size.
height() };
472 data->
is_null = (data->
w <= 0 || data->
h <= 0);
474 #if (Q_DIRECTFB_VERSION >= 0x010000) 489 #ifndef QT_NO_DIRECTFB_PREALLOCATED 493 imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL);
494 imgSurface->Clear(imgSurface, 0, 0, 0, 0);
496 imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
498 imgSurface->Blit(imgSurface,
dfbSurface, 0, 0, 0);
499 #if (Q_DIRECTFB_VERSION >= 0x010000) 500 imgSurface->ReleaseSource(imgSurface);
502 imgSurface->Release(imgSurface);
544 if (result != DFB_OK) {
545 DirectFBError(
"QDirectFBPixmapData::scroll", result);
549 if (result != DFB_OK) {
550 DirectFBError(
"QDirectFBPixmapData::scroll", result);
554 const DFBRectangle source = { rect.
x(), rect.
y(), rect.
width(), rect.
height() };
556 if (result != DFB_OK) {
557 DirectFBError(
"QDirectFBPixmapData::scroll", result);
588 #endif // QT_NO_QWS_DIRECTFB The QColor class provides colors based on RGB, HSV or CMYK values.
virtual bool fromFile(const QString &filename, const char *format, Qt::ImageConversionFlags flags)
QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
Format
The following image formats are available in Qt.
DFBSurfaceLockFlags lockFlgs
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
IDirectFBSurface * createDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options, DFBResult *result=0)
#define QT_END_NAMESPACE
This macro expands to.
T * data() const
Returns the value of the pointer referenced by this object.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
virtual bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
void releaseDFBSurface(IDirectFBSurface *surface)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
The QByteArray class provides an array of bytes.
T * take()
Returns the value of the pointer referenced by this object.
int width() const
Returns the width of the rectangle.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
int bytesPerLine() const
Returns the number of bytes per image scanline.
static void cleanup(T *t)
bool fromDataBufferDescription(const DFBDataBufferDescription &dataBuffer)
ushort red
Returns the red color component of this color.
int height() const
Returns the height of the rectangle.
QImage::Format alphaPixmapFormat() const
The QString class provides a Unicode character string.
virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags)
virtual QImage toImage() const
virtual bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
Format format() const
Returns the format of the image.
QDirectFBPaintEngine * engine
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
DFBSurfaceLockFlags lockFlags() const
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QImage::Format format() const
Returns the format of the device's memory buffet.
virtual QPaintEngine * paintEngine() const
Q_GUI_EXPORT IDirectFBSurface * qt_directfb_surface_for_pixmap(const QPixmap &pixmap)
QSize size() const
Returns the size of the rectangle.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
static const char * data(const QByteArray &arr)
static bool isOpaqueFormat(QImage::Format format)
int depth() const
Returns the depth of the image.
static QImage::Format getImageFormat(IDirectFBSurface *surface)
virtual void copy(const QPixmapData *data, const QRect &rect)
QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
virtual void resize(int width, int height)
IDirectFBSurface * dfbSurface
virtual bool hasAlphaChannel() const =0
const char * constData() const
Returns a pointer to the data stored in the byte array.
uchar * bits()
Returns a pointer to the first pixel data.
int width() const
Returns the width of the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
ushort blue
Returns the blue color component of this color.
The QFile class provides an interface for reading from and writing to files.
ushort alpha
Returns the alpha color component of this color.
int y() const
Returns the y-coordinate of the rectangle's top edge.
virtual QImage * buffer()
int x() const
Returns the x-coordinate of the rectangle's left edge.
int & rheight()
Returns a reference to the height.
virtual void fill(const QColor &color)
virtual void copy(const QPixmapData *data, const QRect &rect)
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
int height() const
Returns the height of the image.
int size() const
Returns the number of bytes in this byte array.
The QPixmap class is an off-screen image representation that can be used as a paint device...
bool hasAlphaChannel() const
The QSize class defines the size of a two-dimensional object using integer point precision.
static QDirectFBScreen * instance()
static bool checkForAlphaPixels(const QImage &img)
virtual IDirectFBSurface * directFBSurface() const
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
virtual QPixmap transformed(const QTransform &matrix, Qt::TransformationMode mode) const
void setSerialNumber(int serNo)
virtual bool fromFile(const QString &filename, const char *format, Qt::ImageConversionFlags flags)
virtual void close()
Calls QFile::flush() and closes the file.
bool lockSurface(DFBSurfaceLockFlags lockFlags)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
ushort green
Returns the green color component of this color.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QImage::Format imageFormat
int & rwidth()
Returns a reference to the width.
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
virtual bool scroll(int dx, int dy, const QRect &rect)
QPixmapData * pixmapData() const