中级会员
 
- 积分
- 251
- 金钱
- 251
- 注册时间
- 2019-8-7
- 在线时间
- 51 小时
|

楼主 |
发表于 2022-4-17 01:47:39
|
显示全部楼层
extern unsigned char data1[] ;
char *p=data1;
size_t input_func ( /* Returns number of bytes read (zero on error) */
JDEC* jd, /* Decompression object */
uint8_t* buff, /* Pointer to the read buffer (null to remove data) */
size_t ndata /* Number of bytes to read/skip */
)
{
if (buff)
{
memcpy(buff,p,ndata);
p+=ndata;
return ndata;
}
else /* Remove bytes from input stream */
{
p+=ndata;
return ndata;
}
}
int output_func ( /* 1:Ok, 0:Aborted */
JDEC* jd, /* Decompression object */
void* bitmap, /* Bitmap data to be output */
JRECT* rect /* Rectangular region to output */
)
{
jd = jd; /* 说明: 输出函数中 JDEC 结构体没有用到 */
LCD_Fill( bitmap, rect->left,rect->top, rect->right- rect->left+1,rect->bottom- rect->top+1);
return 1; /* Continue to decompress */
}
void jpegtest (void)
{
const size_t sz_work = 10000; /* Size of working buffer for TJpgDec module */
unsigned char jdwork[10000]; /* Pointer to TJpgDec work area */
JDEC jd; /* TJpgDec decompression object */
void* iodev; /* Identifier of the decompression session (depends on application) */
JRESULT rc;
uint32_t xs, ys;
/* Prepare to decompress the JPEG image */
rc = jd_prepare(&jd, input_func, jdwork, sz_work, &iodev);
printf("%d", rc);
if (rc == JDR_OK)
{
printf("%u,%u\n", jd.width, jd.height); /* Image dimensions */
printf("%s\n", jd.ncomp == 1 ? "4:0:0" : jd.msx == 1 ? "4:4:4" : jd.msy == 1 ? "4:2:2" : "4:2:0"); /* Sampling ratio */
printf("Used:%u\n", sz_work - jd.sz_pool); /* Used memory size */
printf("UN Used:%u\n", jd.sz_pool); /* Used memory size */
/* Initialize frame buffer */
xs = jd.width >> SCALE; /* Image size to output */
ys = jd.height >> SCALE;
rc = jd_decomp(&jd, output_func, SCALE);
printf("%d", rc);
}
}
|
|