区域管理(REGION&OSD字符显示)
https://www.cdsy.xyz/electronic/Open-source_hardware/230313/cd41429.html
1.freetype下载安装
1.1 下载
https://download.savannah.gnu.org/releases/freetype/
1.2 安装
解压: #tar -xvf freetype-2.4.10.tar.gz
进入freetype文件目录: #cd freetype-2.4.10
执行: # ./configure CC=arm-hisiv600-linux-gcc --host=arm-hisiv600-linux
编译:make && make install
上述命令敲击过后,会在/usr/local/目录下
生成bin目录
生成include目录
生成lib目录
2.SDL下载安装
2.1下载
http://www.libsdl.org/download-1.2.php
2.2安装
解压: #tar -xvf SDL-1.2.15.tar.gz
进入SDL文件目录: #cd SDL-1.2.15/
执行: #./configure CC=arm-hisiv600-linux-gcc --host=arm-hisiv600-linux
问题:
./src/audio/esd/SDL_esdaudio.c:30:17: fatal error: esd.h: 没有那个文件或目录
解决方法:
加上--enable-esd=no,这个错误好像是音频相关的错误,这里直接关掉音频。
问题:
fatal error: pulse/pulseaudio.h: No such file or directory
解决方法:
--disable-pulseaudio
所以:
./configure CC=arm-hisiv600-linux-gcc --host=arm-hisiv600-linux --disable-alsa --disable-pulseaudio --enable-esd=no
make
make install
3.SDL_ttf下载安装
3.1下载
https://pan.baidu.com/s/1mjEyt1u#list/path=%2F
3.2安装
tar xvf SDL_tff.tar
./configure CC=arm-hisiv600-linux-gcc --host=arm-hisiv600-linux --with-freetype-prefix=/usr/local/ --with-sdl-prefix=/usr/local/
问题:
SDL.h:No such file or directory
解决方法1:makefile 的CFLAGS里面加上-I/usr/include/SDL
解决方法2:把上一个SDL编译安装成功,就不会出现这个问题。SDL我make后忘记make install。
make
make intsall
注意:三个库要依次成功安装下来,因为下一个库依赖上一个库。
若上述过程成功,会在/usr/local目录下生成相应文件:
在/usr/local目录下执行tree -L 2(ps:有时间要研究下tree命令),结果如下:
- .
- ├── bin
- │ ├── freetype-config
- │ └── sdl-config
- ├── etc
- ├── games
- ├── include
- │ ├── freetype2
- │ ├── ft2build.h
- │ └── SDL
- ├── lib
- │ ├── libfreetype.a
- │ ├── libfreetype.la
- │ ├── libfreetype.so -> libfreetype.so.6.9.0
- │ ├── libfreetype.so.6 -> libfreetype.so.6.9.0
- │ ├── libfreetype.so.6.9.0
- │ ├── libSDL-1.2.so.0 -> libSDL-1.2.so.0.11.4
- │ ├── libSDL-1.2.so.0.11.4
- │ ├── libSDL.a
- │ ├── libSDL.la
- │ ├── libSDLmain.a
- │ ├── libSDLmain.la
- │ ├── libSDL.so -> libSDL-1.2.so.0.11.4
- │ ├── libSDL_ttf-2.0.so.0 -> libSDL_ttf-2.0.so.0.10.1
- │ ├── libSDL_ttf-2.0.so.0.10.1
- │ ├── libSDL_ttf.a
- │ ├── libSDL_ttf.la
- │ ├── libSDL_ttf.so -> libSDL_ttf-2.0.so.0.10.1
- │ ├── pkgconfig
- │ ├── python2.7
- │ └── python3.5
- ├── man -> share/man
- ├── sbin
- ├── share
- │ ├── aclocal
- │ ├── ca-certificates
- │ ├── emacs
- │ ├── fonts
- │ ├── man
- │ ├── sgml
- │ └── xml
- └── src
4.运行例程
4.1 例程源码
- #include <stdio.h>
- #include "SDL/include/SDL.h"
- #include "SDL_tff/SDL_ttf.h"
-
-
- int main(int argc, const char *argv[])
- {
- char * pstr = "hello";
- SDL_PixelFormat *fmt;
- TTF_Font *font;
- SDL_Surface *text, *temp;
-
- if (TTF_Init() < 0 )
- {
- fprintf(stderr, "Couldn't initialize TTF: %s\n",SDL_GetError());
- SDL_Quit();
- }
-
- font = TTF_OpenFont("./simhei.ttf", 48);
- if ( font == NULL )
- {
- fprintf(stderr, "Couldn't load %d pt font from %s: %s\n",18,"ptsize", SDL_GetError());
- }
-
- SDL_Color forecol = { 0xff, 0xff, 0xff, 0xff };
- text = TTF_RenderUTF8_Solid(font, pstr, forecol);
-
- fmt = (SDL_PixelFormat*)malloc(sizeof(SDL_PixelFormat));
- memset(fmt,0,sizeof(SDL_PixelFormat));
- fmt->BitsPerPixel = 16;
- fmt->BytesPerPixel = 2;
- fmt->colorkey = 0xffffffff;
- fmt->alpha = 0xff;
-
- temp = SDL_ConvertSurface(text,fmt,0);
- SDL_SaveBMP(temp, "save.bmp");
-
- SDL_FreeSurface(text);
- SDL_FreeSurface(temp);
- TTF_CloseFont(font);
- TTF_Quit();
-
- return 0;
- }
4.2 将源码和三个静态库在放同一目录下
4.3 编译运行
- arm-himix200-linux-gcc -o osd_test osd_test.c -I /usr/local/include/osd/ libSDL_ttf.a libfreetype.a libSDL.a -lpthread -lm
将生成的osd_test放到板卡上运行(不能在Ubuntu中直接运行,因为使用的是交叉编译器编译的)。
下载simhei.ttf放在跟osd_test在同一个目录。
运行后会在当前目录成成一个bmp图片。
5.海思region
5.1 因为BMP图片不能设置透明,所以显示的图在视频帧上会导致视频的背景是黑色的,而且无法去除。
解决方法:
- s32Ret = SAMPLE_RGN_UpdateCanvas("sys_time.bmp", &stBitmap, HI_TRUE, 0x8000, &stSize, stCanvasInfo.u32Stride, stRgnAttrSet.unAttr.stOverlayEx.enPixelFmt);