miniGUI 3.0 在Hi3535上的移植之二

之前有介绍将miniGUI3.0移植到Hi3535的平台,并可在输出设备上看到Helloworld示例的显示。本文将进一步讨论如何增加对jpeg和png图片文件的支持。

JPEG文件支持

Hi3535 SDK中包含对jpeg的支持,在mpp/lib路径下,包含libjpeg.a和libjpeg6b.a。因此miniGUI 3.0对jpeg的支持可选用Hi3535 SDK中自带的jpeg库。

首先在配置编译选项时按如下设置对jpeg的支持。

./configure --prefix=[mg_path]/libminigui-3.0.12-linux/_install CC=arm-hisiv100nptl-linux-gcc CFLAGS="-I[sdk_path]/Hi3535_SDK_V1.0.5.0/mpp/include" LDFLAGS="-L[sdk_path]/Hi3535_SDK_V1.0.5.0/mpp/lib" --host=arm-hisiv100nptl-linux --disable-pcxvfb --disable-screensaver --disable-splash --enable-videoqvfb=no --enable-rtosxvfb=no --enable-pcxvfb=no --enable-videohi3535=yes

上述指令中增加了CFLAGS和LDFLAGS的设定,分别指向Hi3535 SDK中jpeg的头文件和库文件所在的位置。另外mg_path为miniGUI代码存储的路径。

默认miniGUI 3.0是支持jpeg的。只是在运行configure脚本时,会自动侦测编译系统是否包含jpeg库,如果不包含,那么自动取消对jpeg的支持。通过LDFLAGS的设定,可使configure脚本运行时,检测到jepg库。

最后重新编译miniGUI3.0。

PNG支持

png文件支持需要zlib和libpng两套代码。可从miniGUI官网下载。

首先编译zlib。官网提供的zlib的版本为1.2.2。解压代码后直接修改代码根目录下的makefile。

#CC=cc
#################
### for Hi3535 ##
#################
CC=arm-hisiv100nptl-linux-gcc

#CFLAGS=-O
#################
### for Hi3535 ##
#################
CFLAGS=-O -g -fPIC -march=armv7-a -mcpu=cortex-a9
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
#           -Wstrict-prototypes -Wmissing-prototypes

LDFLAGS=libz.a
LDSHARED=$(CC)
#################
### for Hi3535 ##
#################
CPP=arm-hisiv100nptl-linux-g++
#CPP=$(CC) -E

LIBS=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.2
SHAREDLIBM=libz.so.1

#################
### for Hi3535 ##
#################
AR=arm-hisiv100nptl-linux-ar rc
RANLIB=arm-hisiv100nptl-linux-ranlib

#AR=ar rc
#RANLIB=ranlib
TAR=tar
SHELL=/bin/sh
EXE=

#################
### for Hi3535 ##
#################
prefix = [zlib_path]/zlib-1.2.2/_install

主要修改交叉编译工具,Hi3535编译选项以及zlib编译完成后生成文件的保存路径[zlib_path]。在实际使用中,根据zlib代码保存的路径修改。_install目录在编译之前手动创建。

运行命令编译,成功后可在_install目录下找到相关的库和头文件。

make 
make install

再编译libpng。官网提供的版本为1.2.37。

运行configure脚本配置。

./configure --host=arm-hisiv100nptl-linux  --prefix=[png_path]/libpng-1.2.37/_install CFLAGS=-I[zlib_path]/zlib-1.2.2/_install/include LDFLAGS=-L[zlib_path]/zlib-1.2.2/_install/lib

注意上述命令中的[zlib_path]和[png_path]需要根据实际的代码或者库的路径修改。

编译

make
make install

最后重新编译miniGUI 3.0

运行configure重新配置

./configure --prefix=[mg_path]/libminigui-3.0.12-linux/_install CC=arm-hisiv100nptl-linux-gcc CFLAGS="-I[sdk_path]/Hi3535_SDK_V1.0.5.0/mpp/include -I[zlib_path]/zlib-1.2.2/_install/include -I[png_path]/libpng-1.2.37/_install/include" LDFLAGS="-L[sdk_path]/Hi3535_SDK_V1.0.5.0/mpp/lib -L[zlib_path]/zlib-1.2.2/_install/lib -L[png_path]/libpng-1.2.37/_install/lib" --host=arm-hisiv100nptl-linux --disable-pcxvfb --disable-screensaver --disable-splash --enable-ctrlgridview=yes --enable-videoqvfb=no --enable-rtosxvfb=no --enable-pcxvfb=no --enable-videohi3535=yes

上述命令增加对--enable-ctrlgridview=yes,因为示例中需要测试gridview。此外所有[]中的内容替换为实际的存储路径。

重新编译可得到新的miniGUI库,该库可支持JPEG和PNG。

测试示例

拷贝全部示例到上篇文中的miniGUI目录下,拷贝zlib和libpng的库到miniGUI/lib目录下。按照下列方式修改makefile。

# Hisilicon Hi3535 sample Makefile

include ../Makefile.param
#ifeq ($(SAMPLE_PARAM_FILE), )
#     SAMPLE_PARAM_FILE:=../Makefile.param
#     include $(SAMPLE_PARAM_FILE)
#endif

# target source
SRC  := $(wildcard *.c) 
OBJ  := $(SRC:%.c=%.o)

TARGET := animation bitblt bmpbkgnd button capture caretdemo combobox coolbar createicon \
			cursordemo dialogbox drawicon edit flame fminigui gridview gridview_ext helloworld \
			iconview input listbox listview loadbmp menubutton mginit monthcal newtoolbar \
			painter progressbar propsheet scrollbar scrollbar_ctrl scrollview scrollwnd \
			scrollwnd2 simplekey spinbox static stretchblt timeeditor trackbar treeview
.PHONY : clean all

all: $(TARGET)

MPI_LIBS := $(REL_LIB)/libmpi.a
MPI_LIBS += $(REL_LIB)/libhdmi.a  $(REL_LIB)/libjpeg.a $(REL_LIB)/libjpeg6b.a
CFLAGS += -I./include 

helloworld: board.o helloworld.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz 

animation: board.o animation.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz

bitblt: board.o bitblt.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz

# jpg support
bmpbkgnd: board.o bmpbkgnd.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz
	
button: board.o button.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz
	
capture: board.o capture.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz
	
caretdemo: board.o caretdemo.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
combobox: board.o combobox.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
coolbar: board.o coolbar.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
createicon: board.o createicon.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
cursordemo: board.o cursordemo.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
dialogbox: board.o dialogbox.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
drawicon: board.o drawicon.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
edit: board.o edit.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
flame: board.o flame.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
fminigui: board.o fminigui.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
gridview: board.o gridview.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
gridview_ext: board.o gridview_ext.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	

# png support	
iconview: board.o iconview.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
input: board.o input.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
listbox: board.o listbox.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
listview: board.o listview.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
# jpg support
loadbmp: board.o loadbmp.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
menubutton: board.o menubutton.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
mginit: board.o mginit.o custom_minigui.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	

monthcal: board.o monthcal.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
# jpg support
newtoolbar: board.o newtoolbar.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
painter: board.o painter.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
progressbar: board.o progressbar.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
propsheet: board.o propsheet.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
scrollbar: board.o scrollbar.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
scrollbar_ctrl: board.o scrollbar_ctrl.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
scrollview: board.o scrollview.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	

# jpg support.	
scrollwnd: board.o scrollwnd.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
scrollwnd2: board.o scrollwnd2.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
simplekey: board.o simplekey.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
spinbox: board.o spinbox.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
static: board.o static.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
stretchblt: board.o stretchblt.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
timeeditor: board.o timeeditor.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
trackbar: board.o trackbar.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
treeview: board.o treeview.o
	$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) -L./lib -lminigui_ths -lpng -lz	
	
%.o:%.c
	$(CC) -c $(CFLAGS) $^ -o $@
	
clean:
	@rm -f $(TARGET)
	@rm -f $(OBJ)

经测试所有的示例均可在Hi3535单板上运行。其中mginit需要稍作修改如下:

#ifdef _MGRM_PROCESSES
static void on_new_del_client (int op, int cli)
{       
    static int nr_clients = 0;

    if (op == LCO_NEW_CLIENT) {
        nr_clients ++;
    }   
    else if (op == LCO_DEL_CLIENT) {
        nr_clients --;
        if (nr_clients == 0) {
            printf ("There is no any client, I will quit.\n");
            quit = TRUE;
        }               
        else if (nr_clients < 0) {
            printf ("Serious error: nr_clients less than zero.\n");
        }
    }
    else
        printf ("Serious error: incorrect operations.\n");
}
#endif

以及:

int MiniGUIMain (int args, const char* arg[])
{
    MSG msg;
    struct sigaction siga;

    siga.sa_handler = child_wait;
    siga.sa_flags  = 0;
    memset (&siga.sa_mask, 0, sizeof(sigset_t));
    sigaction (SIGCHLD, &siga, NULL);
#ifdef _MGRM_PROCESSES
    OnNewDelClient = on_new_del_client;
    if (!ServerStartup (0 , 0 , 0)) {
        fprintf (stderr, 
                 "Can not start the server of MiniGUI-Processes: mginit.\n");
        return 1;
    }


    SetServerEventHook (my_event_hook);
#endif

    if (args > 1) {
        if (exec_app (arg[1], arg[1]) == 0)
            return 3;
    }
    else {
        if (exec_app ("./helloworld", "helloworld") == 0)
            return 3;
    }

    old_tick_count = GetTickCount ();

    while (!quit && GetMessage (&msg, HWND_DESKTOP)) {
        if (pid_scrnsaver == 0 && GetTickCount () > old_tick_count + 1000) {
            ShowCursor (FALSE);
            pid_scrnsaver = exec_app ("./scrnsaver", "scrnsaver");
        }
        DispatchMessage (&msg);
    }

    return 0;
}
测试时,需要同时将mg-samples-3.0.12/src目录下的res文件夹和两个ico文件拷贝的测试的NFS路径下。
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页