import{_ as t}from"./plugin-vue_export-helper-DlAUqK2U.js";import{c as i,a,o as n}from"./app-D3AKSfRn.js";const s={};function p(r,e){return n(),i("div",null,[...e[0]||(e[0]=[a(`

JPEG算法解密(五)

最后,我提供给大家一个简易的jpeg压缩算法的代码,这份代码用C++编写,以开源方式提供,放在了github上,可以到下面这个网址下载
http://github.com/thejinchao/jpeg_encoder
使用方法很简单,像下面这样就可以了

#include "jpeg_encoder.h"
 
JpegEncoder encoder;
//输入的文件必须是24bit的bmp文件,尺寸必须是8的倍数
encoder.readFromBMP(inputFileName);
 
//第二个参数在1~199之间,代表文件压缩程度,数字越大,压缩后的文件体积越小
encoder.encodeToJPG(outputFileName, 50);

这份代码只是为了配合这个系列的文章,所以没有考虑优化,如果你想在实际工程中使用jpeg的压缩算法,还是使用被广泛应用的libjpeg或者OpenJpeg。


参考资料:
【1】http://www.impulseadventure.com/photo/jpeg-huffman-coding.html
【2】http://www.mysanco.cn/index.php?class=wenku&action=wenku_item&id=96
【3】http://www.codingnow.com/2000/download/jpeg.txt
【4】http://jingyan.baidu.com/article/cbf0e500f1ce562eaa2893f4.html
【5】http://www.codeproject.com/Articles/83225/A-Simple-JPEG-Encoder-in-C

`,6)])])}const l=t(s,[["render",p]]),c=JSON.parse('{"path":"/blog/2025/02/JPEG005.html","title":"JPEG算法解密(五)","lang":"zh-CN","frontmatter":{"title":"JPEG算法解密(五)","tags":"压缩 图像 程序 算法","prev":{"text":"JPEG算法解密(四)","link":"JPEG004.md"},"description":"JPEG算法解密(五) 最后,我提供给大家一个简易的jpeg压缩算法的代码,这份代码用C++编写,以开源方式提供,放在了github上,可以到下面这个网址下载 http://github.com/thejinchao/jpeg_encoder 使用方法很简单,像下面这样就可以了 这份代码只是为了配合这个系列的文章,所以没有考虑优化,如果你想在实际工程中...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"JPEG算法解密(五)\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2025-08-31T08:33:30.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"JinChao\\",\\"url\\":\\"https://thecodeway.com\\"}]}"],["meta",{"property":"og:url","content":"https://thejinchao.github.io/blog/2025/02/JPEG005.html"}],["meta",{"property":"og:site_name","content":"我的博客和笔记"}],["meta",{"property":"og:title","content":"JPEG算法解密(五)"}],["meta",{"property":"og:description","content":"JPEG算法解密(五) 最后,我提供给大家一个简易的jpeg压缩算法的代码,这份代码用C++编写,以开源方式提供,放在了github上,可以到下面这个网址下载 http://github.com/thejinchao/jpeg_encoder 使用方法很简单,像下面这样就可以了 这份代码只是为了配合这个系列的文章,所以没有考虑优化,如果你想在实际工程中..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2025-08-31T08:33:30.000Z"}],["meta",{"property":"article:modified_time","content":"2025-08-31T08:33:30.000Z"}]]},"git":{"createdTime":1740225290000,"updatedTime":1756629210000,"contributors":[{"name":"thejinchao","username":"thejinchao","email":"thejinchao@gmail.com","commits":2,"url":"https://github.com/thejinchao"}]},"readingTime":{"minutes":0.95,"words":285},"filePathRelative":"blog/2025/02/JPEG005.md","autoDesc":true}');export{l as comp,c as data};