初级会员
- 积分
- 93
- 金钱
- 93
- 注册时间
- 2015-5-27
- 在线时间
- 11 小时
|
楼主 |
发表于 2015-9-16 14:14:40
|
显示全部楼层
回复【12楼】liliang129129:
---------------------------------
#include "jpegdisplay.h"
#include "GUI.h"
#include "ff.h"
#include "ffconf.h"
#include "diskio.h"
#include "lcd.h"
#define DISP_XS 800
#define DISP_YS 480
FATFS fs4; // ?????????÷??±ê??
static FIL JPEGFile;
static unsigned char jpegBuffer[JPEGPERLINESIZE] __attribute__ ((aligned(4)));
extern void Disp_Mask (
int left, /* Left end of active window (0 to DISP_XS-1) */
int right, /* Right end of active window (0 to DISP_XS-1, >=left) */
int top, /* Top end of active window (0 to DISP_YS-1) */
int bottom /* Bottom end of active window (0 to DISP_YS-1, >=top) */
);
extern void Delay(volatile unsigned int nCount);
/*******************************************************************
*
* Static functions
*
********************************************************************
*/
/*********************************************************************
*
* _GetData
*
* Function description
* This routine is called by GUI_JPEG_DrawEx(). The routine is responsible
* for setting the data pointer to a valid data location with at least
* one valid byte.
*
* arameters:
* p - ointer to application defined data.
* NumBytesReq - Number of bytes requested.
* ppData - ointer to data pointer. This pointer should be set to
* a valid location.
* StartOfFile - If this flag is 1, the data pointer should be set to the
* beginning of the data stream.
*
* Return value:
* Number of data bytes available.
*/
static int JpegGetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
static int readaddress=0;
FIL * phFile;
UINT NumBytesRead;
#if SYSTEM_SUPPORT_UCOS
OS_CPU_SR cpu_sr;
#endif
phFile = (FIL *)p;
if (NumBytesReq > sizeof(jpegBuffer))
{
NumBytesReq = sizeof(jpegBuffer);
}
if(Off == 1) readaddress = 0;
else readaddress=Off;
#if SYSTEM_SUPPORT_UCOS
OS_ENTER_CRITICAL();
#endif
f_lseek(phFile,readaddress);
f_read(phFile,jpegBuffer,NumBytesReq,&NumBytesRead);
#if SYSTEM_SUPPORT_UCOS
OS_EXIT_CRITICAL();
#endif
*ppData = (U8 *)jpegBuffer;
return NumBytesRead;
}
int displayjpegex(u8 *JPEGFileName,u8 mode,u32 x,u32 y,int member,int denom)
{
char result;
int xSize,ySize;
float Xflag,Yflag;
GUI_JPEG_INFO JpegInfo;
DIR dirs;
char path1[50]={""};
disk_initialize(0);
Disp_Mask(0, 800-1, 0, 480-1 );
f_mount(0, &fs4);
if (f_opendir(&dirs, path1) == FR_OK)
{
result = f_open(&JPEGFile,(const TCHAR*)JPEGFileName,FA_OPEN_EXISTING | FA_READ);
if(result != FR_OK) return 1;
GUI_JPEG_GetInfoEx(JpegGetData,&JPEGFile,&JpegInfo);
xSize = JpegInfo.XSize; //JPEG????X?ó??
ySize = JpegInfo.YSize; //JPEG????Y?ó??
switch(mode)
{
case 0:
if((member == 1) && (denom == 1))
{
GUI_JPEG_DrawEx(JpegGetData,&JPEGFile,x,y);
}else
{
GUI_JPEG_DrawScaledEx(JpegGetData,&JPEGFile,x,y,member,denom);
}
break;
case 1:
if((member == 1) && (denom == 1)) //???è??·????±??????
{
// GUI_JPEG_DrawEx(JpegGetData,&JPEGFile,(lcddev.width-XSize)/2-1,(lcddev.height-YSize)/2-1);
GUI_JPEG_DrawEx(JpegGetData,&JPEGFile,(800-xSize)/2-1,(480-ySize)/2-1);
}else
{
Xflag = (float)xSize*((float)member/(float)denom);
Yflag = (float)ySize*((float)member/(float)denom);
xSize = (800-(int)Xflag)/2-1;
ySize = (480-(int)Yflag)/2-1;
GUI_JPEG_DrawScaledEx(JpegGetData,&JPEGFile,xSize,ySize,member,denom);
}
break;
}
f_close(&JPEGFile);
}
return 0;
} |
|