本文整理汇总了C++中IDirectFBSurface::GetPixelFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface::GetPixelFormat方法的具体用法?C++ IDirectFBSurface::GetPixelFormat怎么用?C++ IDirectFBSurface::GetPixelFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFBSurface
的用法示例。
在下文中一共展示了IDirectFBSurface::GetPixelFormat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static int
DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch)
{
Uint32 sdl_format;
unsigned char* laypixels;
int laypitch;
DFBSurfacePixelFormat dfb_format;
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *winsurf = data->target;
DirectFB_ActivateRenderer(renderer);
winsurf->GetPixelFormat(winsurf, &dfb_format);
sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format);
winsurf->Lock(winsurf, DSLF_READ, (void **) &laypixels, &laypitch);
laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) );
SDL_ConvertPixels(rect->w, rect->h,
sdl_format, laypixels, laypitch,
format, pixels, pitch);
winsurf->Unlock(winsurf);
return 0;
}
示例2: OpenDisplay
static int OpenDisplay(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
DFBSurfaceDescription dsc;
/*dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_WIDTH;*/
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
/*dsc.width = 352;*/
/*dsc.height = 240;*/
IDirectFB *directfb = NULL;
if (DirectFBCreate(&directfb) != DFB_OK || !directfb)
return VLC_EGENERIC;
sys->directfb = directfb;
IDirectFBSurface *primary = NULL;
if (directfb->CreateSurface(directfb, &dsc, &primary) || !primary)
return VLC_EGENERIC;
sys->primary = primary;
primary->GetSize(primary, &sys->width, &sys->height);
primary->GetPixelFormat(primary, &sys->pixel_format);
primary->FillRectangle(primary, 0, 0, sys->width, sys->height);
primary->Flip(primary, NULL, 0);
return VLC_SUCCESS;
}
示例3: surface_get_pixel_format
static mrb_value surface_get_pixel_format(mrb_state *mrb, mrb_value self)
{
IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
if (surface != NULL) {
DFBSurfacePixelFormat format;
DFBResult ret = surface->GetPixelFormat(surface, &format);
if (!ret) {
return mrb_fixnum_value(format);
}
}
return mrb_nil_value();
}
示例4: 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);
}
示例5: print_usage
int
main( int argc, char *argv[] )
{
int i;
DFBResult ret;
DFBSurfaceDescription desc;
IDirectFB *dfb;
IDirectFBSurface *dest = NULL;
const char *url = NULL;
DFBFontAttributes attributes = DFFA_NONE;
DFBSurfaceTextFlags text_flags = DSTF_TOPLEFT;
int outline_width = 0x10000;
int outline_opacity = 255;
const DFBColorID color_ids[2] = { DCID_PRIMARY, DCID_OUTLINE };
const DFBColor colors[2] = { { 0xff, 0xff, 0xff, 0xff },
{ 0xff, 0x00, 0x80, 0xff } };
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Font: DirectFBInit() failed!\n" );
return ret;
}
/* Parse arguments. */
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
return print_usage( argv[0] );
else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
return false;
}
else if (strcmp (arg, "-o") == 0 || strcmp (arg, "--outline") == 0) {
attributes |= DFFA_OUTLINED;
text_flags |= DSTF_OUTLINE;
}
else if (strcmp (arg, "-ow") == 0 || strcmp (arg, "--outline-width") == 0) {
if (++i == argc)
return print_usage( argv[0] );
if (sscanf( argv[i], "%d", &outline_width ) != 1)
return print_usage( argv[0] );
outline_width <<= 16;
}
else if (strcmp (arg, "-oo") == 0 || strcmp (arg, "--outline-opacity") == 0) {
if (++i == argc)
return print_usage( argv[0] );
if (sscanf( argv[i], "%d", &outline_opacity ) != 1)
return print_usage( argv[0] );
}
else if (!url)
url = arg;
else
return print_usage( argv[0] );
}
/* Check if we got an URL. */
if (!url)
return print_usage( argv[0] );
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Font: DirectFBCreate() failed!\n" );
return ret;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/Font: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/Font: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
for (i=10; i<50; i++) {
IDirectFBFont *font;
font = CreateFont( dfb, url, i, attributes, outline_width, outline_opacity );
RenderChecker( dest, 64, 64 );
dest->SetColors( dest, color_ids, colors, 2 );
dest->SetFont( dest, font );
//.........这里部分代码省略.........
示例6: print_usage
int
main( int argc, char *argv[] )
{
DFBResult ret;
int i;
DFBSurfaceDescription desc;
IDirectFB *dfb;
IDirectFBSurface *dest = NULL;
DFBSurfacePixelFormat dest_format = DSPF_UNKNOWN;
char pixel_buffer[100*100*4];
IDirectFBSurface *source = NULL;
IDirectFBEventBuffer *keybuffer;
DFBInputEvent evt;
bool quit = false;
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: DirectFBInit() failed!\n" );
return ret;
}
/* Parse arguments. */
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
return print_usage( argv[0] );
else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
return false;
}
else if (strcmp (arg, "-d") == 0 || strcmp (arg, "--dest") == 0) {
if (++i == argc) {
print_usage (argv[0]);
return false;
}
if (!parse_format( argv[i], &dest_format ))
return false;
}
else if (strcmp (arg, "-s") == 0 || strcmp (arg, "--static") == 0) {
static_caps = DSCAPS_STATIC_ALLOC;
}
else
return print_usage( argv[0] );
}
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: DirectFBCreate() failed!\n" );
return ret;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if (dest_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = dest_format;
}
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create an input buffer for key events */
dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS,
DFB_TRUE, &keybuffer);
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: IDirectFB::CreateSurface() for the destination failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/PreAlloc: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a preallocated surface. */
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS | DSDESC_PREALLOCATED;
desc.width = 100;
desc.height = 100;
desc.pixelformat = DSPF_ARGB;
desc.caps = static_caps;
desc.preallocated[0].data = pixel_buffer;
desc.preallocated[0].pitch = 100 * 4;
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/PreAlloc: IDirectFB::CreateSurface() for the preallocated source failed!\n" );
goto out;
}
/* Before any other operation the pixel data can be written to without locking */
gen_pixels( pixel_buffer, 100 * 4, 100 );
//.........这里部分代码省略.........
示例7: print_usage
//.........这里部分代码省略.........
ret = provider->GetSurfaceDescription( provider, &desc );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
goto out;
}
if (source_format != DSPF_UNKNOWN)
desc.pixelformat = source_format;
D_INFO( "DFBTest/Blit: Source is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
/* Create a surface for the image. */
ret = dfb->CreateSurface( dfb, &desc, &source );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
ret = provider->RenderTo( provider, source, NULL );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
goto out;
}
/* Fill description for a primary surface. */
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if (dest_format != DSPF_UNKNOWN) {
desc.flags |= DSDESC_PIXELFORMAT;
desc.pixelformat = dest_format;
}
if (dest_resize)
desc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
/* Create a primary surface. */
ret = dfb->CreateSurface( dfb, &desc, &dest );
if (ret) {
D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
goto out;
}
dest->GetSize( dest, &desc.width, &desc.height );
dest->GetPixelFormat( dest, &desc.pixelformat );
D_INFO( "DFBTest/Blit: Destination is %dx%d using %s\n",
desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
for (i=0; i<100000; i++) {
int j,n = rand()%100;
for (j=0; j<n; j++) {
switch (rand()%3) {
case 0:
dest->SetDrawingFlags( dest, rand() & (DSDRAW_BLEND) );
dest->FillRectangle( dest, rand()%100, rand()%100, rand()%100, rand()%100 );
break;
case 1:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->Blit( dest, source, NULL, rand()%100, rand()%100 );
break;
case 2:
dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
DSBLIT_BLEND_COLORALPHA |
DSBLIT_COLORIZE |
DSBLIT_ROTATE90) );
dest->StretchBlit( dest, source, NULL, NULL );
break;
}
}
dfb->WaitIdle( dfb );
dest->Flip( dest, NULL, DSFLIP_NONE );
}
out:
if (dest)
dest->Release( dest );
if (source)
source->Release( source );
if (provider)
provider->Release( provider );
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}
示例8: testing_singlecore
int testing_singlecore() {
IDirectFB *dfb = NULL;
IDirectFBSurface *surface = NULL;
DFBSurfaceDescription dsc;
DFBSurfaceCapabilities caps;
int width, height;
DFBSurfacePixelFormat p_format;
int i;
DFBCHECK(DirectFBInit(NULL, NULL));
DFBCHECK(DirectFBCreate(&dfb));
push_release(dfb, dfb->Release);
DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &surface ));
push_release(surface, surface->Release);
DFBCHECK(surface->GetCapabilities(surface, &caps));
if (caps & DSCAPS_PRIMARY) {
printf("Surface Primary\n");
}
if (caps & DSCAPS_SYSTEMONLY) {
printf("Surface SystemOnly\n");
}
if (caps & DSCAPS_VIDEOONLY) {
printf("Surface VideoOnly\n");
}
if (caps & DSCAPS_DOUBLE) {
printf("Surface Double buffered\n");
}
if (caps & DSCAPS_SUBSURFACE) {
printf("Surface is a sub surface\n");
}
if (caps & DSCAPS_INTERLACED) {
printf("Surface is Interlaced\n");
}
if (caps & DSCAPS_SEPARATED) {
printf("Surface is separated\n");
}
if (caps & DSCAPS_STATIC_ALLOC) {
printf("Surface is static alloc\n");
}
if (caps & DSCAPS_TRIPLE) {
printf("Surface is triple buffered\n");
}
if (caps & DSCAPS_PREMULTIPLIED) {
printf("Surface stores premiltiplied alpha\n");
}
if (caps & DSCAPS_DEPTH) {
printf("Surface has a depth buffer\n");
}
DFBCHECK(surface->GetSize(surface, &width, &height));
printf("Surface size: %dx%d\n", width, height);
DFBCHECK(surface->GetPixelFormat(surface, &p_format));
for(i = 0; pformat_names[i].format; i++) {
if (pformat_names[i].format == p_format) {
printf("Surface pixelformat: %s\n", pformat_names[i].name);
}
}
release_all();
return 0;
}
示例9: get_display_layer_surface
int get_display_layer_surface() {
int i;
IDirectFB *dfb = NULL;
IDirectFBSurface *surface = NULL;
DFBSurfaceCapabilities caps;
IDirectFBDisplayLayer *layer = NULL;
int width, height;
DFBSurfacePixelFormat p_format;
DFBCHECK(DirectFBInit(NULL, NULL));
DFBCHECK(DirectFBCreate(&dfb));
push_release(dfb, dfb->Release);
DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));
push_release(layer, layer->Release);
DFBCHECK(layer->SetCooperativeLevel(layer, DLSCL_EXCLUSIVE));
DFBCHECK(layer->GetSurface(layer, &surface));
push_release(surface, surface->Release);
DFBCHECK(surface->GetCapabilities(surface, &caps));
if (caps & DSCAPS_PRIMARY) {
printf("Surface Primary\n");
}
if (caps & DSCAPS_SYSTEMONLY) {
printf("Surface SystemOnly\n");
}
if (caps & DSCAPS_VIDEOONLY) {
printf("Surface VideoOnly\n");
}
if (caps & DSCAPS_DOUBLE) {
printf("Surface Double buffered\n");
}
if (caps & DSCAPS_SUBSURFACE) {
printf("Surface is a sub surface\n");
}
if (caps & DSCAPS_INTERLACED) {
printf("Surface is Interlaced\n");
}
if (caps & DSCAPS_SEPARATED) {
printf("Surface is separated\n");
}
if (caps & DSCAPS_STATIC_ALLOC) {
printf("Surface is static alloc\n");
}
if (caps & DSCAPS_TRIPLE) {
printf("Surface is triple buffered\n");
}
if (caps & DSCAPS_PREMULTIPLIED) {
printf("Surface stores premiltiplied alpha\n");
}
if (caps & DSCAPS_DEPTH) {
printf("Surface has a depth buffer\n");
}
DFBCHECK(surface->GetSize(surface, &width, &height));
printf("Surface size: %dx%d\n", width, height);
DFBCHECK(surface->GetPixelFormat(surface, &p_format));
for(i = 0; pformat_names[i].format; i++) {
if (pformat_names[i].format == p_format) {
printf("Surface pixelformat: %s\n", pformat_names[i].name);
}
}
release_all();
return 0;
}
示例10: max
DFBResult
GetConfigAttribs::eglGetConfigAttribs( EGL::Display &display,
EGLNativePixmapType native,
EGLint *attribs,
EGLint max )
{
D_DEBUG_AT( DFBEGL_GetConfigAttribs, "%s( display %p, native %p, attribs %p, max %d )\n", __FUNCTION__, &display, native, attribs, max );
if (!attribs)
return DFB_INVARG;
DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );
IDirectFBSurface *surface = (IDirectFBSurface *) native;
for (EGLint *v=attribs; *v != EGL_NONE; v+=2) {
if (max > 0 && v-attribs >= max) {
D_DEBUG_AT( DFBEGL_GetConfigAttribs, " -> max (%d) reached (%ld)\n", max, v-attribs );
break;
}
EGLint attribute = v[0];
EGLint value = v[1];
DFBSurfacePixelFormat format;
DFBDimension size;
D_DEBUG_AT( DFBEGL_GetConfigAttribs, " -> [%ld] 0x%04x '%s' <- %d (0x%08x)\n", v-attribs, attribute, **EGLInt(attribute), value, value );
switch (attribute) {
case EGL_BUFFER_SIZE:
surface->GetPixelFormat( surface, &format );
value = DFB_COLOR_BITS_PER_PIXEL( format );
break;
case EGL_ALPHA_SIZE:
surface->GetPixelFormat( surface, &format );
value = DFB_ALPHA_BITS_PER_PIXEL( format );
break;
case EGL_BLUE_SIZE:
case EGL_GREEN_SIZE:
case EGL_RED_SIZE:
surface->GetPixelFormat( surface, &format );
value = DFB_COLOR_BITS_PER_PIXEL( format ) / 3;//FIXME
break;
//case EGL_DEPTH_SIZE:
//case EGL_STENCIL_SIZE:
//case EGL_RENDERABLE_TYPE:
case EGL_SURFACE_TYPE:
value = EGL_WINDOW_BIT; // FIXME
break;
case EGL_WIDTH: // keep? not a config attribute actually
surface->GetSize( surface, &size.w, &size.h );
value = size.w;
break;
case EGL_HEIGHT: // keep? not a config attribute actually
surface->GetSize( surface, &size.w, &size.h );
value = size.h;
break;
default:
D_DEBUG_AT( DFBEGL_GetConfigAttribs, " -> UNRECOGNIZED!!!\n" );
continue;
}
D_DEBUG_AT( DFBEGL_GetConfigAttribs, " => %d (0x%08x)\n", value, value );
v[1] = value;
}
D_DEBUG_AT( DFBEGL_GetConfigAttribs, " --> DONE -------------\n" );
DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );
return DFB_OK;
}