0

だから私はC++を試しています.何かから始めます.画像を圧縮するのはかなり簡単だと思います.

そして私のコードは次のとおりです。

void main(){
    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr jerr;
    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_compress(&cinfo);
    FILE* outfile = fopen("/tmp/test.jpeg", "wb");
    jpeg_stdio_dest(&cinfo, outfile);

    //cinfo.image_width      = xinfo.width;
    //cinfo.image_height     = xinfo.height;
    //cinfo.input_components = 3;
    //cinfo.in_color_space   = JCS_RGB;

    jpeg_set_defaults(&cinfo);
    /*set the quality [0..100]  */
    jpeg_set_quality (&cinfo, 75, true);
    jpeg_start_compress(&cinfo, true);
    jpeg_finish_compress(&cinfo);
}

私が取って、別のサイトから少し変更しました。

ご覧のとおり、Xinfo は存在しませんが、私が見つけたその例では、スクリーンショット ライブラリか何かでした。

したがって、ハードドライブにある画像をフィードして圧縮したいだけです。必要以上に難しくしたくありません。

http://www.andrewewhite.net/wordpress/2008/09/02/very-simple-jpeg-writer-in-cc/

4

0 に答える 0