本文整理汇总了C++中IDirectFBSurface::GetPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface::GetPalette方法的具体用法?C++ IDirectFBSurface::GetPalette怎么用?C++ IDirectFBSurface::GetPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFBSurface
的用法示例。
在下文中一共展示了IDirectFBSurface::GetPalette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
{
if (data->classId() != DirectFBClass) {
QPixmapData::copy(data, rect);
return;
}
IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->surface;
DFBSurfaceDescription description;
description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
DSDESC_HEIGHT |
DSDESC_PIXELFORMAT);
description.width = rect.width();
description.height = rect.height();
src->GetPixelFormat(src, &description.pixelformat);
IDirectFB *fb = QDirectFBScreen::instance()->dfb();
DFBResult result = fb->CreateSurface(fb, &description, &surface);
if (result != DFB_OK) {
DirectFBError("QDirectFBPixmapData::copy()", result);
setSerialNumber(0);
return;
}
#ifndef QT_NO_DIRECTFB_PALETTE
IDirectFBPalette *palette;
src->GetPalette(src, &palette);
surface->SetPalette(surface, palette);
#endif
surface->SetBlittingFlags(surface, DSBLIT_NOFX);
const DFBRectangle blitRect = { rect.x(), rect.y(),
rect.width(), rect.height() };
result = surface->Blit(surface, src, &blitRect, 0, 0);
if (result != DFB_OK)
DirectFBError("QDirectFBPixmapData::copy()", result);
setSerialNumber(++global_ser_no);
}
示例2: main
//.........这里部分代码省略.........
// We want to create an Image Provider tied to a directfb data buffer.
// DirectFB will find (or not) an Image Provider for the data type
// depending on Image Providers probe method (sniffing data headers)
DFBCHECK (databuffer->CreateImageProvider (databuffer, &provider));
}
else {
# ifdef USE_PACKET_BUILDER_ONLY
DFBFAIL(rle_build_databuffer_err);
# else
// We could also create an Image Provider by passing a filename.
// DirectFB will find (or not) an Image Provider matching the file type.
DFBCHECK (dfb->CreateImageProvider (dfb, filename, &provider));
# endif
}
// Get a surface description from the provider. It will contain the width,
// height, bits per pixel and the flag for an alphachannel if the image
// has one. If the image has no alphachannel the bits per pixel is set to
// the bits per pixel of the primary layer to use simple blitting without
// pixel format conversion.
DFBCHECK (provider->GetSurfaceDescription (provider, &surface_dsc));
// Create a surface based on the description of the provider.
DFBCHECK (dfb->CreateSurface( dfb, &surface_dsc, &logo ));
// Let the provider render to our surface. Image providers are supposed
// to support every destination pixel format and size. If the size
// differs the image will be scaled (bilinear). The last parameter allows
// to specify an optional destination rectangle. We use NULL here so that
// our image covers the whole logo surface.
DFBCHECK (provider->RenderTo (provider, logo, NULL));
// Note: RLE Image Provider allows for direct non-scaled LUT-8 surface
// rendering without any attached colormap.
#ifdef CLEVER_APPROACH
// Let's setup our logo surface palette outside of the RLE Image
// Provider if we got a colormap from rle_build_databuffer ...
if (color_palette)
{
IDirectFBPalette *palette;
DFBCHECK (logo->GetPalette (logo, &palette));
palette->SetEntries (palette, color_palette, number_of_colors, 0);
palette->Release (palette);
}
#endif
//
// --- WE GET RID OF OUR IMAGE PROVIDER INSTANCE HERE
//
// Release the provider, we don't need it anymore.
provider->Release (provider); provider = NULL;
// Destroy the databuffer as well, we don't need it anymore.
rle_destroy_databuffer (databuffer); databuffer = NULL;
# ifndef SUBTITLES_MODE
// We want to let the logo slide in on the left and slide out on the
// right.
for (i = -surface_dsc.width; i < screen_width; i++)
# else
// We want to let the logo slide in on the right and slide out on the
// left.
for (i = screen_width-1; i >= -surface_dsc.width; i--)
# endif
{
// Clear the screen.
DFBCHECK (primary->FillRectangle (primary, 0, 0,
screen_width, screen_height));
// Blit the logo vertically centered with "i" as the X coordinate.
// NULL means that we want to blit the whole surface.
DFBCHECK (primary->Blit (primary, logo, NULL, i,
(screen_height - surface_dsc.height) / 2));
// Flip the front and back buffer, but wait for the vertical
// retrace to avoid tearing.
DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
if (argc < 3)
{
usleep(1000*5);
}
}
// Release the image.
if (logo)
{
logo->Release (logo);
}
}
// Release everything else
primary->Release (primary);
dfb->Release (dfb);
return 0;
}