我得到了directfb 图像示例,我正在尝试 blit 图像,如此处所述。所以,这是我的代码:
#include <stdio.h>
#include <unistd.h>
#include <directfb.h>
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width = 0;
static int screen_height = 0;
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
/* reflection against y */
static int DFB_FIXED_POINT_ONE = 1;
static const s32 mat_y[9] = {
-DFB_FIXED_POINT_ONE, 0, 0,
0, DFB_FIXED_POINT_ONE, 0,
0, 0, DFB_FIXED_POINT_ONE
};
static IDirectFBSurface *logo = NULL;
int main(int argc, char **argv) {
int i;
DFBSurfaceDescription dsc;
IDirectFBImageProvider *provider;
DFBCHECK(DirectFBInit (&argc, &argv));
DFBCHECK(DirectFBCreate (&dfb));
DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY | DSCAPS_FLIPPING);
DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));
DFBCHECK(primary->GetSize (primary, &screen_width, &screen_height));
DFBCHECK(dfb->CreateImageProvider (dfb, "iconC.png", &provider));
DFBCHECK(provider->GetSurfaceDescription (provider, &dsc));
DFBCHECK(dfb->CreateSurface( dfb, &dsc, &logo ));
DFBCHECK(provider->RenderTo (provider, logo, NULL));
provider->Release(provider);
for (i = -dsc.width; i < screen_width; i++) {
DFBCHECK(primary->SetRenderOptions(primary, DSRO_MATRIX));
DFBCHECK(primary->SetMatrix(primary, mat_y));
DFBCHECK(primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
DFBCHECK(primary->Blit (primary, logo, NULL, i, (screen_height - dsc.height) / 2));
DFBCHECK(primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
usleep(1000*10); // 10 microseconds
}
logo->Release(logo);
primary->Release(primary);
dfb->Release(dfb);
return 23;
}
这个程序的输出有很多:
`(!!!) *** WARNING [rotation not yet implemented] *** [gfxcard.c:2075 in dfb_gfxcard_blit()]`
`(!!!) *** WARNING [rotation not yet implemented] *** [gfxcard.c:2075 in dfb_gfxcard_blit()]`
`(!!!) *** WARNING [rotation not yet implemented] *** [gfxcard.c:2075 in dfb_gfxcard_blit()]`
这是我的 DFB 版本的问题吗?我正在使用 DirectFB 1.4.11。
有没有办法让这个例子运行并blit图像?
*(顺便说一句,我不理解 DFB_FIXED_POINT_ONE 变量,所以我给它任何值来尝试)*