1

我得到了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 变量,所以我给它任何值来尝试)*

4

1 回答 1

1

我想让 directfb 显示旋转 90 度的所有内容,这似乎是一个很好的起点。

有两点需要考虑:

首先,数字是定点 16.16 fmt - 所以高位是整数部分,低 16 位是小数部分 - 所以 0x10000 代表 1(即 1 << 16),而 0xffff0000 代表 -1(即 - 1 << 16)。

其次,计算似乎是针对实际(而不是标准化)屏幕坐标进行的,计算结果需要在范围 0 .. screen width - 1 for X 和 0 .. screen height - 1 for Y to被显示。

在您的情况下,正确的矩阵似乎是:

{
    (-1 < 16), 0,         ((screen_width - 1) << 16),
    0,         (1 << 16), 0,
    0,         0,         (1 << 16),
}

请注意第一行的最后一项,它将 X 坐标移回 X 坐标的正确范围。

于 2014-06-18T06:27:20.520 回答