嵌入式圖像顯示
在最開始接觸嵌入式LINUX的時候就嘗試做了将一個BMP圖檔顯示在嵌入式framebuffer顯示器中,但是對于jpeg與png圖檔沒有什麼辦法,在完成了LiteCV的底層架構後,就實作這個圖像顯示的程式。
使用方式:
./display /dev/fb0 PATH(.jpg,.bmp,.png)
/*
* @Descripttion: 基于嵌入式LINUX的diplay程式
* @version: V1.0
* @Author: Yueyang
* @email: [email protected]
* @Date: 2020-11-24 18:54:21
* @LastEditors: Yueyang
* @LastEditTime: 2020-11-24 19:27:48
* @Use: ./display /dev/fb0 PATH(.jpg,.bmp,.png)
*/
#include "string.h"
#include "fb.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "cv.h"
#include "li_image.h"
#ifdef __cplusplus
}
#endif
int main(int argc,char** argv)
{
Li_Image* out;
if(argc!=3)return 0;
Painter* p=new Painter(argv[1]);
if(strstr(argv[2],"bmp")!=NULL)
out=Li_Load_Image((BYTE*)argv[2],BMP_888);
else if(strstr(argv[2],"png")!=NULL)
out=Li_Load_Image((BYTE*)argv[2],PNG);
else if(strstr(argv[2],"jpg")!=NULL)
out=Li_Load_Image((BYTE*)argv[2],JPEG);
else
out=Li_Load_Image((BYTE*)argv[2],BMP_888);
Li_Image* ffb=Li_ReShape(out,p->width,p->height);
for(int i=0;i<ffb->height;i++)
for(int j=0;j<ffb->width;j++)
{
BYTE* ptr=(BYTE*) ffb->at(ffb,j,i);
p->Point(j,p->height- i,LI_RGB(*(ptr+2),*(ptr+1),*(ptr)));
}
Li_Save_Image((BYTE*)"2.bmp",ffb);
return 0;
}
代碼中有錯誤的地方還望指出。我已經将項目同步到了github,我會實時更新這個代碼倉庫。
項目github位址:
LiteCV