Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.*/
- #include <stdio.h>
- #include "jpeglib.h"
- int main() {
- struct jpeg_decompress_struct srcinfo;
- struct jpeg_error_mgr srcerr;
- jvirt_barray_ptr *coef;
- JBLOCKARRAY coef_array;
- int c;
- JDIMENSION n_rows, n_cols, y, x;
- srcinfo.err = jpeg_std_error(&srcerr);
- jpeg_create_decompress(&srcinfo);
- jpeg_stdio_src(&srcinfo, stdin);
- jpeg_read_header(&srcinfo, TRUE);
- coef = jpeg_read_coefficients(&srcinfo);
- for (c = 0; c < srcinfo.num_components; c++) {
- n_rows = srcinfo.comp_info[c].height_in_blocks;
- n_cols = srcinfo.comp_info[c].width_in_blocks;
- for (y = 0; y < n_rows; y++) {
- coef_array = (*srcinfo.mem->access_virt_barray)((j_common_ptr) &srcinfo, coef[c], y, 1, FALSE);
- for (x = 0; x < n_cols; x++) {
- if (fwrite(coef_array[0][x], sizeof(JCOEF), DCTSIZE2, stdout) != DCTSIZE2) {
- fprintf(stderr, "Error writing coefficients\n");
- }
- }
- }
- }
- jpeg_finish_decompress(&srcinfo);
- jpeg_destroy_decompress(&srcinfo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement