comparison libinterp/dldfcn/__magick_read__.cc @ 20441:5b8e4f668c53

Add compression option to imwrite and default to "none" (bug #45565) * libinterp/dldfcn/__magick_read__.cc: we did not specify compression type and let it up to GM coder. However, Matlab users seem to be expect it to be uncompressed since Matlab only does that (except for jpeg). So we add the compression method and apply to the images being writen. * scripts/image/imwrite.m: document new option and add tests (bug was about bmp and type compression is defined at offset byte 30) * scripts/image/private/__imwrite__.m: parse new compression option.
author Carnë Draug <carandraug@octave.org>
date Tue, 28 Jul 2015 17:43:23 +0100
parents a7770c66cb3d
children b70cc4bd8109
comparison
equal deleted inserted replaced
20440:e3f84a8c6788 20441:5b8e4f668c53
1548 // Because of this, we document to set LoopCount on every iteration 1548 // Because of this, we document to set LoopCount on every iteration
1549 // (in Matlab will cause a lot of warnings), or pass a 4D matrix with 1549 // (in Matlab will cause a lot of warnings), or pass a 4D matrix with
1550 // all frames (won't work in Matlab at all). 1550 // all frames (won't work in Matlab at all).
1551 // Note that this only needs to be set on the first frame 1551 // Note that this only needs to be set on the first frame
1552 imvec[0].animationIterations (options.getfield ("loopcount").uint_value ()); 1552 imvec[0].animationIterations (options.getfield ("loopcount").uint_value ());
1553
1554 const std::string compression = options.getfield ("compression").string_value ();
1555 #define COMPRESS_MAGICK_IMAGE_VECTOR(COMPRESSION_STRING, GM_TYPE) \
1556 if (compression == COMPRESSION_STRING) \
1557 for (std::vector<Magick::Image>::size_type i = 0; i < imvec.size (); i++) \
1558 imvec[i].compressType (GM_TYPE);
1559
1560 COMPRESS_MAGICK_IMAGE_VECTOR("none", Magick::NoCompression)
1561 else COMPRESS_MAGICK_IMAGE_VECTOR("bzip", Magick::BZipCompression)
1562 else COMPRESS_MAGICK_IMAGE_VECTOR("fax3", Magick::FaxCompression)
1563 else COMPRESS_MAGICK_IMAGE_VECTOR("fax4", Magick::Group4Compression)
1564 else COMPRESS_MAGICK_IMAGE_VECTOR("jpeg", Magick::JPEGCompression)
1565 else COMPRESS_MAGICK_IMAGE_VECTOR("lzw", Magick::LZWCompression)
1566 else COMPRESS_MAGICK_IMAGE_VECTOR("rle", Magick::RLECompression)
1567 else COMPRESS_MAGICK_IMAGE_VECTOR("deflate", Magick::ZipCompression)
1568
1569 #undef COMPRESS_MAGICK_IMAGE_VECTOR
1553 1570
1554 write_file (filename, ext, imvec); 1571 write_file (filename, ext, imvec);
1555 if (error_state) 1572 if (error_state)
1556 return retval; 1573 return retval;
1557 1574