博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DirectFB 之 实例图像不断右移
阅读量:4669 次
发布时间:2019-06-09

本文共 2815 字,大约阅读时间需要 9 分钟。

/********************************************** * Author: younger.liucn@gmail.com * File name: imgrotate.c * Description: animation * Modified: *   date:   2014-01-06  create *********************************************/#include 
#include "animation.h"#define MAX_LOOP 2#define INTERVAL_PIXEL 2#define EYE_HZ 50#define INTERVAL_TIME (1000 / EYE_HZ)static int animation(int argc, char **argv);int main(int argc, char **argv){ return animation(argc, argv);}static int animation(int argc, char **argv){ int i, loop = 0; int screen_width = 0, screen_height = 0; DFBSurfaceDescription dsc; /* * For collecting infomation of image, * and provide image to IDirectFBSurface */ IDirectFBImageProvider *provider; IDirectFB *dfb = NULL; IDirectFBSurface *primary = NULL; IDirectFBSurface *logo = NULL; /* 初始化整个DirectFB库,为后续画图等操作做准备 */ DirectFBInit(&argc, &argv); DirectFBCreate(&dfb); /* 设置协作等级为全屏模式,具体请阅读SetCooperativeLevel接口解析 */ dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN); dsc.flags = DSDESC_CAPS; dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING; /* 根据dsc创建一个基本平面 */ dfb->CreateSurface(dfb, &dsc, &primary); /* 获取该基本平面的宽度和高度 */ primary->GetSize(primary, &screen_width, &screen_height); /* 将要显示的图片及其相关信息保存在provider中 */ dfb->CreateImageProvider(dfb, BA_IMG_NAME, &provider); /* 将保存在provider中的图片信息提取出来,存于dsc中 */ provider->GetSurfaceDescription(provider, &dsc); /* 根据dsc创建一个图像平面 */ dfb->CreateSurface(dfb, &dsc, &logo); /* 将图片呈递给刚才建立的logo平面,如果大小不一,则进行缩放 */ provider->RenderTo(provider, logo, NULL); /* 释放资源provider */ provider->Release(provider); for (i = -dsc.width; i < screen_width && !ba_check_exit(shared_mem); i = i + INTERVAL_PIXEL) { /* 清空屏幕 */ primary->FillRectangle(primary, 0, 0, screen_width, screen_height); primary->Blit(primary, logo, NULL, i, (screen_height - dsc.height) / 2); /* * Blit model:将图片blit到平面 * Blit(IDirectFBSurface *thiz, IDirectFBSurface *source, * const DFBRectangle *source_rect, int x, int y); * if source_rect == NULL,use entire surface. * DFBRctangle is rectangular frame defined by two points. * (x, y):the point of top left corner. */ /* flit整个屏幕 */ primary->Flip(primary, NULL, DSFLIP_WAITFORSYNC); msleep(INTERVAL_TIME); if ((screen_width - INTERVAL_PIXEL) <= i && loop < MAX_LOOP) { BA_LOG(1, "screen_width:%d, loop:%d.\n", screen_width, loop); loop++; i = -dsc.width; } } logo->Release(logo); primary->Release(primary); dfb->Release(dfb); return 0;}

转载于:https://www.cnblogs.com/youngerchina/p/5624511.html

你可能感兴趣的文章
电容计算公式
查看>>
MySQL高可用架构故障自动转移插件MHA
查看>>
recv send 阻塞和非阻塞
查看>>
网络丢包分析
查看>>
打印LIS
查看>>
剑指offer第2章学习(2)
查看>>
java后台验证码的生成
查看>>
Bootstrap辅助类
查看>>
vue项目的骨架及常用组件介绍
查看>>
Spring使用外部的配置文件
查看>>
ctype
查看>>
jsp 修饰 Request 及Response
查看>>
HDU 2389 Rain on your Parade / HUST 1164 4 Rain on your Parade(二分图的最大匹配)
查看>>
对象的类型转换P109
查看>>
sqlite 查询表和字段是否存在
查看>>
http => https 升级
查看>>
Window 分布式学习-好文收藏
查看>>
Android TextUtils类介绍
查看>>
linux echo设置颜色
查看>>
英文参考文献标准格式:论文参考文献格式规范(转载)
查看>>