如何解决C 中的 Tiny JPEG Decompressor:增加除垢因子
我将这个 Tiny JPEG Decompressor 用于我在 STM32F4 中的嵌入式项目。我意识到我需要进一步缩小我的图像,但 Tiny JPEG Decompressor 仅支持 (1/2)^N (N = 0 到 3) 缩小。
我查看了它的 C 源代码,但不确定在哪里编辑它,以便我可以将除垢因子增加到 N=4 和 N=5。
这是除垢的部分:
JRESULT jd_decomp (JDEC* jd,uint16_t (*outfunc)(JDEC*,void*,JRECT*),uint8_t scale){
uint16_t x,y,mx,my;
uint16_t rst,rsc;
JRESULT rc;
if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR;
jd->scale = scale;
mx = jd->msx * 8; my = jd->msy * 8; /* Size of the MCU (pixel) */
jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */
rst = rsc = 0;
rc = JDR_OK;
for (y = 0; y < jd->height; y += my) { /* Vertical loop of MCUs */
for (x = 0; x < jd->width; x += mx) { /* Horizontal loop of MCUs */
if (jd->nrst && rst++ == jd->nrst) { /* Process restart interval if enabled */
rc = restart(jd,rsc++);
if (rc != JDR_OK) return rc;
rst = 1;
}
rc = mcu_load(jd); /* Load an MCU (decompress huffman coded stream and apply IDCT) */
if (rc != JDR_OK) return rc;
rc = mcu_output(jd,outfunc,x,y); /* Output the MCU (color space conversion,scaling and output) */
if (rc != JDR_OK) return rc;
}
}
return rc;}
C 文件也可以在这里下载:JPEG Decompressor Source Code
如果有人能帮忙,我非常感谢。
问候, 提姆
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。