Mercurial > octave-nkf
comparison libinterp/dldfcn/__magick_read__.cc @ 17787:175b392e91fe
Use GNU style coding conventions for code in libinterp/
* libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h,
libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc,
libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc,
libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc,
libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc,
libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc,
libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h,
libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h,
libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc,
libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc,
libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc,
libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc,
libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h,
libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc,
libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc,
libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc,
libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc,
libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h,
libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h,
libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h,
libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h,
libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h,
libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc,
libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc,
libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc,
libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc,
libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc,
libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc,
libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc,
libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc,
libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc,
libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc,
libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc,
libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc,
libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/ops.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h,
libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h,
libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h,
libinterp/parse-tree/token.h, libinterp/version.cc:
Use GNU style coding conventions for code in libinterp/
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Oct 2013 19:51:46 -0700 |
parents | d63878346099 |
children | aacb9da13df6 |
comparison
equal
deleted
inserted
replaced
17786:34d9812a943b | 17787:175b392e91fe |
---|---|
209 const octave_idx_type def_elem = frameidx(0); | 209 const octave_idx_type def_elem = frameidx(0); |
210 | 210 |
211 T img = T (dim_vector (nRows, nCols, 1, nFrames)); | 211 T img = T (dim_vector (nRows, nCols, 1, nFrames)); |
212 P* img_fvec = img.fortran_vec (); | 212 P* img_fvec = img.fortran_vec (); |
213 | 213 |
214 const octave_idx_type row_start = region["row_start"]; | 214 const octave_idx_type row_start = region["row_start"]; |
215 const octave_idx_type col_start = region["col_start"]; | 215 const octave_idx_type col_start = region["col_start"]; |
216 const octave_idx_type row_shift = region["row_shift"]; | 216 const octave_idx_type row_shift = region["row_shift"]; |
217 const octave_idx_type col_shift = region["col_shift"]; | 217 const octave_idx_type col_shift = region["col_shift"]; |
218 const octave_idx_type row_cache = region["row_cache"]; | 218 const octave_idx_type row_cache = region["row_cache"]; |
219 const octave_idx_type col_cache = region["col_cache"]; | 219 const octave_idx_type col_cache = region["col_cache"]; |
220 | 220 |
221 // When reading PixelPackets from the Image Pixel Cache, they come in | 221 // When reading PixelPackets from the Image Pixel Cache, they come in |
222 // row major order. So we keep moving back and forth there so we can | 222 // row major order. So we keep moving back and forth there so we can |
223 // write the image in column major order. | 223 // write the image in column major order. |
224 octave_idx_type idx = 0; | 224 octave_idx_type idx = 0; |
240 pix -= col_shift; | 240 pix -= col_shift; |
241 } | 241 } |
242 } | 242 } |
243 retval(0) = octave_value (img); | 243 retval(0) = octave_value (img); |
244 | 244 |
245 // Only bother reading the colormap if it was requested as output. | 245 // Only bother reading the colormap if it was requested as output. |
246 if (nargout > 1) | 246 if (nargout > 1) |
247 { | 247 { |
248 // In theory, it should be possible for each frame of an image to | 248 // In theory, it should be possible for each frame of an image to |
249 // have different colormaps but for Matlab compatibility, we only | 249 // have different colormaps but for Matlab compatibility, we only |
250 // return the colormap of the first frame. To obtain the colormaps | 250 // return the colormap of the first frame. To obtain the colormaps |
301 // imvec has all of the pages of a file, even the ones we are not | 301 // imvec has all of the pages of a file, even the ones we are not |
302 // interested in. We will use the first image that we will be actually | 302 // interested in. We will use the first image that we will be actually |
303 // reading to get information about the image. | 303 // reading to get information about the image. |
304 const octave_idx_type def_elem = frameidx(0); | 304 const octave_idx_type def_elem = frameidx(0); |
305 | 305 |
306 const octave_idx_type row_start = region["row_start"]; | 306 const octave_idx_type row_start = region["row_start"]; |
307 const octave_idx_type col_start = region["col_start"]; | 307 const octave_idx_type col_start = region["col_start"]; |
308 const octave_idx_type row_shift = region["row_shift"]; | 308 const octave_idx_type row_shift = region["row_shift"]; |
309 const octave_idx_type col_shift = region["col_shift"]; | 309 const octave_idx_type col_shift = region["col_shift"]; |
310 const octave_idx_type row_cache = region["row_cache"]; | 310 const octave_idx_type row_cache = region["row_cache"]; |
311 const octave_idx_type col_cache = region["col_cache"]; | 311 const octave_idx_type col_cache = region["col_cache"]; |
312 | 312 |
313 // GraphicsMagick (GM) keeps the image values in memory using whatever | 313 // GraphicsMagick (GM) keeps the image values in memory using whatever |
314 // QuantumDepth it was built with independently of the original image | 314 // QuantumDepth it was built with independently of the original image |
315 // bitdepth. Basically this means that if GM was built with quantum 16 | 315 // bitdepth. Basically this means that if GM was built with quantum 16 |
316 // all values are scaled in the uint16 range. If the original image | 316 // all values are scaled in the uint16 range. If the original image |
360 // RGB = 2 | 360 // RGB = 2 |
361 // RGB + Alpha = 2 + 4 | 361 // RGB + Alpha = 2 + 4 |
362 // Grayscale + Alpha = 4 | 362 // Grayscale + Alpha = 4 |
363 // We won't bother with case 3 (palette) since those should be | 363 // We won't bother with case 3 (palette) since those should be |
364 // read by the function to read indexed images | 364 // read by the function to read indexed images |
365 const std::string type_str = imvec[0].attribute ("PNG:IHDR.color-type-orig"); | 365 const std::string type_str |
366 = imvec[0].attribute ("PNG:IHDR.color-type-orig"); | |
367 | |
366 if (type_str == "0") | 368 if (type_str == "0") |
367 type = Magick::GrayscaleType; | 369 type = Magick::GrayscaleType; |
368 else if (type_str == "2") | 370 else if (type_str == "2") |
369 type = Magick::TrueColorType; | 371 type = Magick::TrueColorType; |
370 else if (type_str == "6") | 372 else if (type_str == "6") |
504 } | 506 } |
505 } | 507 } |
506 break; | 508 break; |
507 } | 509 } |
508 | 510 |
509 case Magick::PaletteMatteType: // Indexed color (palette) image with opacity | 511 case Magick::PaletteMatteType: // Indexed color image with opacity |
510 case Magick::TrueColorMatteType: // Truecolor image with opacity | 512 case Magick::TrueColorMatteType: // Truecolor image with opacity |
511 { | 513 { |
512 img = T (dim_vector (nRows, nCols, 3, nFrames)); | 514 img = T (dim_vector (nRows, nCols, 3, nFrames)); |
513 T alpha (dim_vector (nRows, nCols, 1, nFrames)); | 515 T alpha (dim_vector (nRows, nCols, 1, nFrames)); |
514 P *img_fvec = img.fortran_vec (); | 516 P *img_fvec = img.fortran_vec (); |
515 P *a_fvec = alpha.fortran_vec (); | 517 P *a_fvec = alpha.fortran_vec (); |
545 } | 547 } |
546 retval(2) = alpha; | 548 retval(2) = alpha; |
547 break; | 549 break; |
548 } | 550 } |
549 | 551 |
550 case Magick::ColorSeparationType: // Cyan/Yellow/Magenta/Black (CYMK) image | 552 case Magick::ColorSeparationType: // Cyan/Magenta/Yellow/Black (CMYK) image |
551 { | 553 { |
552 img = T (dim_vector (nRows, nCols, 4, nFrames)); | 554 img = T (dim_vector (nRows, nCols, 4, nFrames)); |
553 P *img_fvec = img.fortran_vec (); | 555 P *img_fvec = img.fortran_vec (); |
554 | 556 |
555 for (octave_idx_type frame = 0; frame < nFrames; frame++) | 557 for (octave_idx_type frame = 0; frame < nFrames; frame++) |
674 // Save locale as GraphicsMagick might change this (fixed in | 676 // Save locale as GraphicsMagick might change this (fixed in |
675 // GraphicsMagick since version 1.3.13 released on December 24, 2011) | 677 // GraphicsMagick since version 1.3.13 released on December 24, 2011) |
676 const char *static_locale = setlocale (LC_ALL, NULL); | 678 const char *static_locale = setlocale (LC_ALL, NULL); |
677 const std::string locale (static_locale); | 679 const std::string locale (static_locale); |
678 | 680 |
679 const std::string program_name = octave_env::get_program_invocation_name (); | 681 const std::string program_name |
682 = octave_env::get_program_invocation_name (); | |
680 Magick::InitializeMagick (program_name.c_str ()); | 683 Magick::InitializeMagick (program_name.c_str ()); |
681 | 684 |
682 // Restore locale from before GraphicsMagick initialisation | 685 // Restore locale from before GraphicsMagick initialisation |
683 setlocale (LC_ALL, locale.c_str ()); | 686 setlocale (LC_ALL, locale.c_str ()); |
684 | 687 |
690 } | 693 } |
691 } | 694 } |
692 #endif | 695 #endif |
693 | 696 |
694 DEFUN_DLD (__magick_read__, args, nargout, | 697 DEFUN_DLD (__magick_read__, args, nargout, |
695 "-*- texinfo -*-\n\ | 698 "-*- texinfo -*-\n\ |
696 @deftypefn {Loadable Function} {[@var{img}, @var{map}, @var{alpha}] =} __magick_read__ (@var{fname}, @var{options})\n\ | 699 @deftypefn {Loadable Function} {[@var{img}, @var{map}, @var{alpha}] =} __magick_read__ (@var{fname}, @var{options})\n\ |
697 Read image with GraphicsMagick or ImageMagick.\n\ | 700 Read image with GraphicsMagick or ImageMagick.\n\ |
698 \n\ | 701 \n\ |
699 This is a private internal function not intended for direct use. Instead\n\ | 702 This is a private internal function not intended for direct use. Instead\n\ |
700 use @code{imread}.\n\ | 703 use @code{imread}.\n\ |
852 // FIXME: for some reason, setting bitdepth doesn't seem to work for | 855 // FIXME: for some reason, setting bitdepth doesn't seem to work for |
853 // indexed images. | 856 // indexed images. |
854 img.depth (bitdepth); | 857 img.depth (bitdepth); |
855 switch (type) | 858 switch (type) |
856 { | 859 { |
857 case Magick::GrayscaleMatteType: | 860 case Magick::GrayscaleMatteType: |
858 case Magick::TrueColorMatteType: | 861 case Magick::TrueColorMatteType: |
859 case Magick::ColorSeparationMatteType: | 862 case Magick::ColorSeparationMatteType: |
860 case Magick::PaletteMatteType: | 863 case Magick::PaletteMatteType: |
861 img.matte (true); | 864 img.matte (true); |
862 break; | 865 break; |
863 | 866 |
864 default: | 867 default: |
865 img.matte (false); | 868 img.matte (false); |
866 } | 869 } |
867 | 870 |
868 return img; | 871 return img; |
869 } | 872 } |
870 | 873 |
912 // there is no conversion from the indexes, it's the initial values | 915 // there is no conversion from the indexes, it's the initial values |
913 // that get used. An alternative would be to only set the pixel | 916 // that get used. An alternative would be to only set the pixel |
914 // values (no indexes), then set the image as PseudoClass and GM | 917 // values (no indexes), then set the image as PseudoClass and GM |
915 // would create a colormap for us. However, we wouldn't have control | 918 // would create a colormap for us. However, we wouldn't have control |
916 // over the order of that colormap. And that's why we set both. | 919 // over the order of that colormap. And that's why we set both. |
917 Magick::PixelPacket* pix = m_img.getPixels (0, 0, nCols, nRows); | 920 Magick::PixelPacket* pix = m_img.getPixels (0, 0, nCols, nRows); |
918 Magick::IndexPacket* ind = m_img.getIndexes (); | 921 Magick::IndexPacket* ind = m_img.getIndexes (); |
919 const P* img_fvec = img.fortran_vec (); | 922 const P* img_fvec = img.fortran_vec (); |
920 | 923 |
921 octave_idx_type GM_idx = 0; | 924 octave_idx_type GM_idx = 0; |
922 for (octave_idx_type column = 0; column < nCols; column++) | 925 for (octave_idx_type column = 0; column < nCols; column++) |
923 { | 926 { |
924 for (octave_idx_type row = 0; row < nRows; row++) | 927 for (octave_idx_type row = 0; row < nRows; row++) |
986 static void | 989 static void |
987 encode_uint_image (std::vector<Magick::Image>& imvec, | 990 encode_uint_image (std::vector<Magick::Image>& imvec, |
988 const T& img, const T& alpha) | 991 const T& img, const T& alpha) |
989 { | 992 { |
990 typedef typename T::element_type P; | 993 typedef typename T::element_type P; |
991 const octave_idx_type channels = img.ndims () < 3 ? 1 : img.dims ()(2); | 994 const octave_idx_type channels = img.ndims () < 3 ? 1 : img.dims ()(2); |
992 const octave_idx_type nFrames = img.ndims () < 4 ? 1 : img.dims ()(3); | 995 const octave_idx_type nFrames = img.ndims () < 4 ? 1 : img.dims ()(3); |
993 const octave_idx_type nRows = img.rows (); | 996 const octave_idx_type nRows = img.rows (); |
994 const octave_idx_type nCols = img.columns (); | 997 const octave_idx_type nCols = img.columns (); |
995 const octave_idx_type bitdepth = bitdepth_from_class<T> (); | 998 const octave_idx_type bitdepth = bitdepth_from_class<T> (); |
996 | 999 |
997 Magick::ImageType type; | 1000 Magick::ImageType type; |
998 const bool has_alpha = ! alpha.is_empty (); | 1001 const bool has_alpha = ! alpha.is_empty (); |
999 switch (channels) | 1002 switch (channels) |
1000 { | 1003 { |
1032 // of the actual depth of the image. GM will then convert the values but | 1035 // of the actual depth of the image. GM will then convert the values but |
1033 // while in memory, it always keeps the values as specified by QuantumDepth. | 1036 // while in memory, it always keeps the values as specified by QuantumDepth. |
1034 // From GM documentation: | 1037 // From GM documentation: |
1035 // Color arguments are must be scaled to fit the Quantum size according to | 1038 // Color arguments are must be scaled to fit the Quantum size according to |
1036 // the range of MaxRGB | 1039 // the range of MaxRGB |
1037 const double divisor = static_cast<double>((uint64_t (1) << bitdepth) - 1) / MaxRGB; | 1040 const double divisor = static_cast<double>((uint64_t (1) << bitdepth) - 1) |
1041 / MaxRGB; | |
1038 | 1042 |
1039 const P *img_fvec = img.fortran_vec (); | 1043 const P *img_fvec = img.fortran_vec (); |
1040 const P *a_fvec = alpha.fortran_vec (); | 1044 const P *a_fvec = alpha.fortran_vec (); |
1041 switch (type) | 1045 switch (type) |
1042 { | 1046 { |
1275 } | 1279 } |
1276 | 1280 |
1277 #endif | 1281 #endif |
1278 | 1282 |
1279 DEFUN_DLD (__magick_write__, args, , | 1283 DEFUN_DLD (__magick_write__, args, , |
1280 "-*- texinfo -*-\n\ | 1284 "-*- texinfo -*-\n\ |
1281 @deftypefn {Loadable Function} {} __magick_write__ (@var{fname}, @var{fmt}, @var{img}, @var{map}, @var{options})\n\ | 1285 @deftypefn {Loadable Function} {} __magick_write__ (@var{fname}, @var{fmt}, @var{img}, @var{map}, @var{options})\n\ |
1282 Write image with GraphicsMagick or ImageMagick.\n\ | 1286 Write image with GraphicsMagick or ImageMagick.\n\ |
1283 \n\ | 1287 \n\ |
1284 This is a private internal function not intended for direct use. Instead\n\ | 1288 This is a private internal function not intended for direct use. Instead\n\ |
1285 use @code{imwrite}.\n\ | 1289 use @code{imwrite}.\n\ |
1343 // values, GM seems unable to do that so we at least make them uint32. | 1347 // values, GM seems unable to do that so we at least make them uint32. |
1344 uint32NDArray clip_img; | 1348 uint32NDArray clip_img; |
1345 uint32NDArray clip_alpha; | 1349 uint32NDArray clip_alpha; |
1346 if (img.is_single_type ()) | 1350 if (img.is_single_type ()) |
1347 { | 1351 { |
1348 clip_img = img_float2uint<FloatNDArray> (img.float_array_value ()); | 1352 clip_img = img_float2uint<FloatNDArray> |
1349 clip_alpha = img_float2uint<FloatNDArray> (alpha.float_array_value ()); | 1353 (img.float_array_value ()); |
1354 clip_alpha = img_float2uint<FloatNDArray> | |
1355 (alpha.float_array_value ()); | |
1350 } | 1356 } |
1351 else | 1357 else |
1352 { | 1358 { |
1353 clip_img = img_float2uint<NDArray> (img.array_value ()); | 1359 clip_img = img_float2uint<NDArray> (img.array_value ()); |
1354 clip_alpha = img_float2uint<NDArray> (alpha.array_value ()); | 1360 clip_alpha = img_float2uint<NDArray> (alpha.array_value ()); |
1392 if (writemode == "append" && file_stat (filename).exists ()) | 1398 if (writemode == "append" && file_stat (filename).exists ()) |
1393 { | 1399 { |
1394 std::vector<Magick::Image> ini_imvec; | 1400 std::vector<Magick::Image> ini_imvec; |
1395 read_file (filename, ini_imvec); | 1401 read_file (filename, ini_imvec); |
1396 if (error_state) | 1402 if (error_state) |
1397 return retval; | 1403 return retval; |
1398 if (ini_imvec.size () > 0) | 1404 if (ini_imvec.size () > 0) |
1399 { | 1405 { |
1400 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ()); | 1406 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ()); |
1401 ini_imvec.swap (imvec); | 1407 ini_imvec.swap (imvec); |
1402 } | 1408 } |
1418 // Gets the minimum information from images such as its size and format. Much | 1424 // Gets the minimum information from images such as its size and format. Much |
1419 // faster than using imfinfo, which slows down a lot since. Note than without | 1425 // faster than using imfinfo, which slows down a lot since. Note than without |
1420 // this, we need to read the image once for imfinfo to set defaults (which is | 1426 // this, we need to read the image once for imfinfo to set defaults (which is |
1421 // done in Octave language), and then again for the actual reading. | 1427 // done in Octave language), and then again for the actual reading. |
1422 DEFUN_DLD (__magick_ping__, args, , | 1428 DEFUN_DLD (__magick_ping__, args, , |
1423 "-*- texinfo -*-\n\ | 1429 "-*- texinfo -*-\n\ |
1424 @deftypefn {Loadable Function} {} __magick_ping__ (@var{fname}, @var{idx})\n\ | 1430 @deftypefn {Loadable Function} {} __magick_ping__ (@var{fname}, @var{idx})\n\ |
1425 Ping image information with GraphicsMagick or ImageMagick.\n\ | 1431 Ping image information with GraphicsMagick or ImageMagick.\n\ |
1426 \n\ | 1432 \n\ |
1427 This is a private internal function not intended for direct use.\n\ | 1433 This is a private internal function not intended for direct use.\n\ |
1428 \n\ | 1434 \n\ |
1478 static octave_value | 1484 static octave_value |
1479 magick_to_octave_value (const Magick::CompressionType& magick) | 1485 magick_to_octave_value (const Magick::CompressionType& magick) |
1480 { | 1486 { |
1481 switch (magick) | 1487 switch (magick) |
1482 { | 1488 { |
1483 case Magick::NoCompression: | 1489 case Magick::NoCompression: |
1484 return octave_value ("none"); | 1490 return octave_value ("none"); |
1485 case Magick::BZipCompression: | 1491 case Magick::BZipCompression: |
1486 return octave_value ("bzip"); | 1492 return octave_value ("bzip"); |
1487 case Magick::FaxCompression: | 1493 case Magick::FaxCompression: |
1488 return octave_value ("fax3"); | 1494 return octave_value ("fax3"); |
1489 case Magick::Group4Compression: | 1495 case Magick::Group4Compression: |
1490 return octave_value ("fax4"); | 1496 return octave_value ("fax4"); |
1491 case Magick::JPEGCompression: | 1497 case Magick::JPEGCompression: |
1492 return octave_value ("jpeg"); | 1498 return octave_value ("jpeg"); |
1493 case Magick::LZWCompression: | 1499 case Magick::LZWCompression: |
1494 return octave_value ("lzw"); | 1500 return octave_value ("lzw"); |
1495 case Magick::RLECompression: | 1501 case Magick::RLECompression: |
1496 // This is named "rle" for the HDF, but the same thing is named | 1502 // This is named "rle" for the HDF, but the same thing is named |
1497 // "ccitt" and "PackBits" for binary and non-binary images in TIFF. | 1503 // "ccitt" and "PackBits" for binary and non-binary images in TIFF. |
1498 return octave_value ("rle"); | 1504 return octave_value ("rle"); |
1499 case Magick::ZipCompression: | 1505 case Magick::ZipCompression: |
1500 return octave_value ("deflate"); | 1506 return octave_value ("deflate"); |
1501 | 1507 |
1502 // The following are present only in recent versions of GraphicsMagick. | 1508 // The following are present only in recent versions of GraphicsMagick. |
1503 // At the moment the only use of this would be to have imfinfo report | 1509 // At the moment the only use of this would be to have imfinfo report |
1504 // the compression method. In the future, someone could implement | 1510 // the compression method. In the future, someone could implement |
1505 // the Compression option for imwrite in which case a macro in | 1511 // the Compression option for imwrite in which case a macro in |
1506 // configure.ac will have to check for their presence of this. | 1512 // configure.ac will have to check for their presence of this. |
1507 // See bug #39913 | 1513 // See bug #39913 |
1508 // case Magick::LZMACompression: | 1514 // case Magick::LZMACompression: |
1509 // return octave_value ("lzma"); | 1515 // return octave_value ("lzma"); |
1510 // case Magick::JPEG2000Compression: | 1516 // case Magick::JPEG2000Compression: |
1511 // return octave_value ("jpeg2000"); | 1517 // return octave_value ("jpeg2000"); |
1512 // case Magick::JBIG1Compression: | 1518 // case Magick::JBIG1Compression: |
1513 // return octave_value ("jbig1"); | 1519 // return octave_value ("jbig1"); |
1514 // case Magick::JBIG2Compression: | 1520 // case Magick::JBIG2Compression: |
1515 // return octave_value ("jbig2"); | 1521 // return octave_value ("jbig2"); |
1516 default: | 1522 default: |
1517 return octave_value ("undefined"); | 1523 return octave_value ("undefined"); |
1518 } | 1524 } |
1519 } | 1525 } |
1520 | 1526 |
1521 static octave_value | 1527 static octave_value |
1522 magick_to_octave_value (const Magick::EndianType& magick) | 1528 magick_to_octave_value (const Magick::EndianType& magick) |
1523 { | 1529 { |
1524 switch (magick) | 1530 switch (magick) |
1525 { | 1531 { |
1526 case Magick::LSBEndian: | 1532 case Magick::LSBEndian: |
1527 return octave_value ("little-endian"); | 1533 return octave_value ("little-endian"); |
1528 case Magick::MSBEndian: | 1534 case Magick::MSBEndian: |
1529 return octave_value ("big-endian"); | 1535 return octave_value ("big-endian"); |
1530 default: | 1536 default: |
1531 return octave_value ("undefined"); | 1537 return octave_value ("undefined"); |
1532 } | 1538 } |
1533 } | 1539 } |
1534 | 1540 |
1535 static octave_value | 1541 static octave_value |
1536 magick_to_octave_value (const Magick::OrientationType& magick) | 1542 magick_to_octave_value (const Magick::OrientationType& magick) |
1537 { | 1543 { |
1538 switch (magick) | 1544 switch (magick) |
1539 { | 1545 { |
1540 // Values come from the TIFF6 spec | 1546 // Values come from the TIFF6 spec |
1541 case Magick::TopLeftOrientation: | 1547 case Magick::TopLeftOrientation: |
1542 return octave_value (1); | 1548 return octave_value (1); |
1543 case Magick::TopRightOrientation: | 1549 case Magick::TopRightOrientation: |
1544 return octave_value (2); | 1550 return octave_value (2); |
1545 case Magick::BottomRightOrientation: | 1551 case Magick::BottomRightOrientation: |
1546 return octave_value (3); | 1552 return octave_value (3); |
1547 case Magick::BottomLeftOrientation: | 1553 case Magick::BottomLeftOrientation: |
1548 return octave_value (4); | 1554 return octave_value (4); |
1549 case Magick::LeftTopOrientation: | 1555 case Magick::LeftTopOrientation: |
1550 return octave_value (5); | 1556 return octave_value (5); |
1551 case Magick::RightTopOrientation: | 1557 case Magick::RightTopOrientation: |
1552 return octave_value (6); | 1558 return octave_value (6); |
1553 case Magick::RightBottomOrientation: | 1559 case Magick::RightBottomOrientation: |
1554 return octave_value (7); | 1560 return octave_value (7); |
1555 case Magick::LeftBottomOrientation: | 1561 case Magick::LeftBottomOrientation: |
1556 return octave_value (8); | 1562 return octave_value (8); |
1557 default: | 1563 default: |
1558 return octave_value (1); | 1564 return octave_value (1); |
1559 } | 1565 } |
1560 } | 1566 } |
1561 | 1567 |
1562 static octave_value | 1568 static octave_value |
1563 magick_to_octave_value (const Magick::ResolutionType& magick) | 1569 magick_to_octave_value (const Magick::ResolutionType& magick) |
1564 { | 1570 { |
1565 switch (magick) | 1571 switch (magick) |
1566 { | 1572 { |
1567 case Magick::PixelsPerInchResolution: | 1573 case Magick::PixelsPerInchResolution: |
1568 return octave_value ("Inch"); | 1574 return octave_value ("Inch"); |
1569 case Magick::PixelsPerCentimeterResolution: | 1575 case Magick::PixelsPerCentimeterResolution: |
1570 return octave_value ("Centimeter"); | 1576 return octave_value ("Centimeter"); |
1571 default: | 1577 default: |
1572 return octave_value ("undefined"); | 1578 return octave_value ("undefined"); |
1573 } | 1579 } |
1574 } | 1580 } |
1575 | 1581 |
1576 // Meant to be shared with both imfinfo and imwrite. | 1582 // Meant to be shared with both imfinfo and imwrite. |
1577 static std::map<octave_idx_type, std::string> | 1583 static std::map<octave_idx_type, std::string> |
1669 } | 1675 } |
1670 | 1676 |
1671 #endif | 1677 #endif |
1672 | 1678 |
1673 DEFUN_DLD (__magick_finfo__, args, , | 1679 DEFUN_DLD (__magick_finfo__, args, , |
1674 "-*- texinfo -*-\n\ | 1680 "-*- texinfo -*-\n\ |
1675 @deftypefn {Loadable Function} {} __magick_finfo__ (@var{fname})\n\ | 1681 @deftypefn {Loadable Function} {} __magick_finfo__ (@var{fname})\n\ |
1676 Read image information with GraphicsMagick or ImageMagick.\n\ | 1682 Read image information with GraphicsMagick or ImageMagick.\n\ |
1677 \n\ | 1683 \n\ |
1678 This is a private internal function not intended for direct use. Instead\n\ | 1684 This is a private internal function not intended for direct use. Instead\n\ |
1679 use @code{imfinfo}.\n\ | 1685 use @code{imfinfo}.\n\ |
1719 // Bad things happen if we merge octave_scalar_maps with different | 1725 // Bad things happen if we merge octave_scalar_maps with different |
1720 // fields from the others (suppose for example a TIFF file with 4 images, | 1726 // fields from the others (suppose for example a TIFF file with 4 images, |
1721 // where only the third image has a colormap. | 1727 // where only the third image has a colormap. |
1722 | 1728 |
1723 static const char *fields[] = | 1729 static const char *fields[] = |
1724 { | 1730 { |
1725 // These are fields that must always appear for Matlab. | 1731 // These are fields that must always appear for Matlab. |
1726 "Filename", | 1732 "Filename", |
1727 "FileModDate", | 1733 "FileModDate", |
1728 "FileSize", | 1734 "FileSize", |
1729 "Format", | 1735 "Format", |
1730 "FormatVersion", | 1736 "FormatVersion", |
1731 "Width", | 1737 "Width", |
1732 "Height", | 1738 "Height", |
1733 "BitDepth", | 1739 "BitDepth", |
1734 "ColorType", | 1740 "ColorType", |
1735 | 1741 |
1736 // These are format specific or not existent in Matlab. The most | 1742 // These are format specific or not existent in Matlab. The most |
1737 // annoying thing is that Matlab may have different names for the | 1743 // annoying thing is that Matlab may have different names for the |
1738 // same thing in different formats. | 1744 // same thing in different formats. |
1739 "DelayTime", | 1745 "DelayTime", |
1740 "DisposalMethod", | 1746 "DisposalMethod", |
1741 "LoopCount", | 1747 "LoopCount", |
1742 "ByteOrder", | 1748 "ByteOrder", |
1743 "Gamma", | 1749 "Gamma", |
1744 "Chromaticities", | 1750 "Chromaticities", |
1745 "Comment", | 1751 "Comment", |
1746 "Quality", | 1752 "Quality", |
1747 "Compression", // same as CompressionType | 1753 "Compression", // same as CompressionType |
1748 "Colormap", // same as ColorTable (in PNG) | 1754 "Colormap", // same as ColorTable (in PNG) |
1749 "Orientation", | 1755 "Orientation", |
1750 "ResolutionUnit", | 1756 "ResolutionUnit", |
1751 "XResolution", | 1757 "XResolution", |
1752 "YResolution", | 1758 "YResolution", |
1753 "Software", // sometimes is an Exif tag | 1759 "Software", // sometimes is an Exif tag |
1754 "Make", // actually an Exif tag | 1760 "Make", // actually an Exif tag |
1755 "Model", // actually an Exif tag | 1761 "Model", // actually an Exif tag |
1756 "DateTime", // actually an Exif tag | 1762 "DateTime", // actually an Exif tag |
1757 "ImageDescription", // actually an Exif tag | 1763 "ImageDescription", // actually an Exif tag |
1758 "Artist", // actually an Exif tag | 1764 "Artist", // actually an Exif tag |
1759 "Copyright", // actually an Exif tag | 1765 "Copyright", // actually an Exif tag |
1760 "DigitalCamera", | 1766 "DigitalCamera", |
1761 "GPSInfo", | 1767 "GPSInfo", |
1762 // Notes for the future: GM allows to get many attributes, and even has | 1768 // Notes for the future: GM allows to get many attributes, and even has |
1763 // attribute() to obtain arbitrary ones, that may exist in only some | 1769 // attribute() to obtain arbitrary ones, that may exist in only some |
1764 // cases. The following is a list of some methods and into what possible | 1770 // cases. The following is a list of some methods and into what possible |
1765 // Matlab compatible values they may be converted. | 1771 // Matlab compatible values they may be converted. |
1766 // | 1772 // |
1767 // colorSpace() -> PhotometricInterpretation | 1773 // colorSpace() -> PhotometricInterpretation |
1768 // backgroundColor() -> BackgroundColor | 1774 // backgroundColor() -> BackgroundColor |
1769 // interlaceType() -> Interlaced, InterlaceType, and PlanarConfiguration | 1775 // interlaceType() -> Interlaced, InterlaceType, and PlanarConfiguration |
1770 // label() -> Title | 1776 // label() -> Title |
1771 0 | 1777 0 |
1772 }; | 1778 }; |
1773 | 1779 |
1774 // The one we will return at the end | 1780 // The one we will return at the end |
1775 octave_map info (dim_vector (nFrames, 1), string_vector (fields)); | 1781 octave_map info (dim_vector (nFrames, 1), string_vector (fields)); |
1776 | 1782 |
1777 // Some of the fields in the struct are about file information and will be | 1783 // Some of the fields in the struct are about file information and will be |
1805 const Magick::Image img = imvec[frame]; | 1811 const Magick::Image img = imvec[frame]; |
1806 | 1812 |
1807 info_frame.setfield ("Width", octave_value (img.columns ())); | 1813 info_frame.setfield ("Width", octave_value (img.columns ())); |
1808 info_frame.setfield ("Height", octave_value (img.rows ())); | 1814 info_frame.setfield ("Height", octave_value (img.rows ())); |
1809 info_frame.setfield ("BitDepth", | 1815 info_frame.setfield ("BitDepth", |
1810 octave_value (get_depth (const_cast<Magick::Image&> (img)))); | 1816 octave_value (get_depth (const_cast<Magick::Image&> (img)))); |
1811 | 1817 |
1812 // Stuff related to colormap, image class and type | 1818 // Stuff related to colormap, image class and type |
1813 // Because GM is too smart for us... Read the comments in is_indexed() | 1819 // Because GM is too smart for us... Read the comments in is_indexed() |
1814 { | 1820 { |
1815 std::string color_type; | 1821 std::string color_type; |
1816 Matrix cmap; | 1822 Matrix cmap; |
1817 if (is_indexed (img)) | 1823 if (is_indexed (img)) |
1818 { | 1824 { |
1819 color_type = "indexed"; | 1825 color_type = "indexed"; |
1820 cmap = read_maps (const_cast<Magick::Image&> (img))(0).matrix_value (); | 1826 cmap = |
1827 read_maps (const_cast<Magick::Image&> (img))(0).matrix_value (); | |
1821 } | 1828 } |
1822 else | 1829 else |
1823 { | 1830 { |
1824 switch (img.type ()) | 1831 switch (img.type ()) |
1825 { | 1832 { |
1826 case Magick::BilevelType: | 1833 case Magick::BilevelType: |
1827 case Magick::GrayscaleType: | 1834 case Magick::GrayscaleType: |
1828 case Magick::GrayscaleMatteType: | 1835 case Magick::GrayscaleMatteType: |
1829 color_type = "grayscale"; | 1836 color_type = "grayscale"; |
1830 break; | 1837 break; |
1831 | 1838 |
1832 case Magick::TrueColorType: | 1839 case Magick::TrueColorType: |
1833 case Magick::TrueColorMatteType: | 1840 case Magick::TrueColorMatteType: |
1834 color_type = "truecolor"; | 1841 color_type = "truecolor"; |
1835 break; | 1842 break; |
1836 | 1843 |
1837 case Magick::PaletteType: | 1844 case Magick::PaletteType: |
1838 case Magick::PaletteMatteType: | 1845 case Magick::PaletteMatteType: |
1839 // we should never get here or is_indexed needs to be fixed | 1846 // we should never get here or is_indexed needs to be fixed |
1840 color_type = "indexed"; | 1847 color_type = "indexed"; |
1841 break; | 1848 break; |
1842 | 1849 |
1843 case Magick::ColorSeparationType: | 1850 case Magick::ColorSeparationType: |
1844 case Magick::ColorSeparationMatteType: | 1851 case Magick::ColorSeparationMatteType: |
1845 color_type = "CMYK"; | 1852 color_type = "CMYK"; |
1846 break; | 1853 break; |
1847 | 1854 |
1848 default: | 1855 default: |
1849 color_type = "undefined"; | 1856 color_type = "undefined"; |
1850 } | 1857 } |
1851 } | 1858 } |
1852 info_frame.setfield ("ColorType", octave_value (color_type)); | 1859 info_frame.setfield ("ColorType", octave_value (color_type)); |
1853 info_frame.setfield ("Colormap", octave_value (cmap)); | 1860 info_frame.setfield ("Colormap", octave_value (cmap)); |
1854 } | 1861 } |
1866 if (chromaticities.nnz () == 0) | 1873 if (chromaticities.nnz () == 0) |
1867 chromaticities = RowVector (0); | 1874 chromaticities = RowVector (0); |
1868 info_frame.setfield ("Chromaticities", octave_value (chromaticities)); | 1875 info_frame.setfield ("Chromaticities", octave_value (chromaticities)); |
1869 } | 1876 } |
1870 | 1877 |
1871 info_frame.setfield ("Gamma", octave_value (img.gamma ())); | 1878 info_frame.setfield ("Gamma", octave_value (img.gamma ())); |
1872 info_frame.setfield ("XResolution", octave_value (img.xResolution ())); | 1879 info_frame.setfield ("XResolution", octave_value (img.xResolution ())); |
1873 info_frame.setfield ("YResolution", octave_value (img.yResolution ())); | 1880 info_frame.setfield ("YResolution", octave_value (img.yResolution ())); |
1874 info_frame.setfield ("DelayTime", octave_value (img.animationDelay ())); | 1881 info_frame.setfield ("DelayTime", octave_value (img.animationDelay ())); |
1875 info_frame.setfield ("LoopCount", octave_value (img.animationIterations ())); | 1882 info_frame.setfield ("LoopCount", |
1876 info_frame.setfield ("Quality", octave_value (img.quality ())); | 1883 octave_value (img.animationIterations ())); |
1877 info_frame.setfield ("Comment", octave_value (img.comment ())); | 1884 info_frame.setfield ("Quality", octave_value (img.quality ())); |
1885 info_frame.setfield ("Comment", octave_value (img.comment ())); | |
1878 | 1886 |
1879 info_frame.setfield ("Compression", | 1887 info_frame.setfield ("Compression", |
1880 magick_to_octave_value (img.compressType ())); | 1888 magick_to_octave_value (img.compressType ())); |
1881 info_frame.setfield ("Orientation", | 1889 info_frame.setfield ("Orientation", |
1882 magick_to_octave_value (img.orientation ())); | 1890 magick_to_octave_value (img.orientation ())); |
1883 info_frame.setfield ("ResolutionUnit", | 1891 info_frame.setfield ("ResolutionUnit", |
1884 magick_to_octave_value (img.resolutionUnits ())); | 1892 magick_to_octave_value (img.resolutionUnits ())); |
1885 info_frame.setfield ("ByteOrder", | 1893 info_frame.setfield ("ByteOrder", |
1886 magick_to_octave_value (img.endian ())); | 1894 magick_to_octave_value (img.endian ())); |
1887 | 1895 |
1888 // It is not possible to know if there's an Exif field so we just | 1896 // It is not possible to know if there's an Exif field so we just |
1889 // check for the Exif Version value. If it does exists, then we | 1897 // check for the Exif Version value. If it does exists, then we |
1890 // bother about looking for specific fields. | 1898 // bother about looking for specific fields. |
1891 { | 1899 { |
1896 // This is likely because they belong to the Baseline TIFF specs | 1904 // This is likely because they belong to the Baseline TIFF specs |
1897 // and may appear out of the Exif tag. So first we check if it | 1905 // and may appear out of the Exif tag. So first we check if it |
1898 // exists outside the Exif tag. | 1906 // exists outside the Exif tag. |
1899 // See Section 4.6.4, table 4, page 28 of Exif specs version 2.3 | 1907 // See Section 4.6.4, table 4, page 28 of Exif specs version 2.3 |
1900 // (CIPA DC- 008-Translation- 2010) | 1908 // (CIPA DC- 008-Translation- 2010) |
1901 static const char *base_exif_str_fields[] = { | 1909 static const char *base_exif_str_fields[] = |
1910 { | |
1902 "DateTime", | 1911 "DateTime", |
1903 "ImageDescription", | 1912 "ImageDescription", |
1904 "Make", | 1913 "Make", |
1905 "Model", | 1914 "Model", |
1906 "Software", | 1915 "Software", |
1911 static const string_vector base_exif_str (base_exif_str_fields); | 1920 static const string_vector base_exif_str (base_exif_str_fields); |
1912 static const octave_idx_type n_base_exif_str = base_exif_str.numel (); | 1921 static const octave_idx_type n_base_exif_str = base_exif_str.numel (); |
1913 for (octave_idx_type field = 0; field < n_base_exif_str; field++) | 1922 for (octave_idx_type field = 0; field < n_base_exif_str; field++) |
1914 { | 1923 { |
1915 info_frame.setfield (base_exif_str[field], | 1924 info_frame.setfield (base_exif_str[field], |
1916 octave_value (cimg.attribute (base_exif_str[field]))); | 1925 octave_value (cimg.attribute (base_exif_str[field]))); |
1917 fill_exif (info_frame, cimg, base_exif_str[field]); | 1926 fill_exif (info_frame, cimg, base_exif_str[field]); |
1918 } | 1927 } |
1919 | 1928 |
1920 octave_scalar_map camera; | 1929 octave_scalar_map camera; |
1921 octave_scalar_map gps; | 1930 octave_scalar_map gps; |
1923 { | 1932 { |
1924 // See Section 4.6.5, table 7 and 8, over pages page 42 to 43 | 1933 // See Section 4.6.5, table 7 and 8, over pages page 42 to 43 |
1925 // of Exif specs version 2.3 (CIPA DC- 008-Translation- 2010) | 1934 // of Exif specs version 2.3 (CIPA DC- 008-Translation- 2010) |
1926 | 1935 |
1927 // Listed on the Exif specs as being of type ASCII. | 1936 // Listed on the Exif specs as being of type ASCII. |
1928 static const char *exif_str_fields[] = { | 1937 static const char *exif_str_fields[] = |
1938 { | |
1929 "RelatedSoundFile", | 1939 "RelatedSoundFile", |
1930 "DateTimeOriginal", | 1940 "DateTimeOriginal", |
1931 "DateTimeDigitized", | 1941 "DateTimeDigitized", |
1932 "SubSecTime", | 1942 "SubSecTime", |
1933 "DateTimeOriginal", | 1943 "DateTimeOriginal", |
1950 static const octave_idx_type n_exif_str = exif_str.numel (); | 1960 static const octave_idx_type n_exif_str = exif_str.numel (); |
1951 for (octave_idx_type field = 0; field < n_exif_str; field++) | 1961 for (octave_idx_type field = 0; field < n_exif_str; field++) |
1952 fill_exif (camera, cimg, exif_str[field]); | 1962 fill_exif (camera, cimg, exif_str[field]); |
1953 | 1963 |
1954 // Listed on the Exif specs as being of type SHORT or LONG. | 1964 // Listed on the Exif specs as being of type SHORT or LONG. |
1955 static const char *exif_int_fields[] = { | 1965 static const char *exif_int_fields[] = |
1966 { | |
1956 "ColorSpace", | 1967 "ColorSpace", |
1957 "ExifImageWidth", // PixelXDimension (CPixelXDimension in Matlab) | 1968 "ExifImageWidth", // PixelXDimension (CPixelXDimension in Matlab) |
1958 "ExifImageHeight", // PixelYDimension (CPixelYDimension in Matlab) | 1969 "ExifImageHeight", // PixelYDimension (CPixelYDimension in Matlab) |
1959 "PhotographicSensitivity", | 1970 "PhotographicSensitivity", |
1960 "StandardOutputSensitivity", | 1971 "StandardOutputSensitivity", |
1993 static const octave_idx_type n_exif_int = exif_int.numel (); | 2004 static const octave_idx_type n_exif_int = exif_int.numel (); |
1994 for (octave_idx_type field = 0; field < n_exif_int; field++) | 2005 for (octave_idx_type field = 0; field < n_exif_int; field++) |
1995 fill_exif_ints (camera, cimg, exif_int[field]); | 2006 fill_exif_ints (camera, cimg, exif_int[field]); |
1996 | 2007 |
1997 // Listed as RATIONAL or SRATIONAL | 2008 // Listed as RATIONAL or SRATIONAL |
1998 static const char *exif_float_fields[] = { | 2009 static const char *exif_float_fields[] = |
2010 { | |
1999 "Gamma", | 2011 "Gamma", |
2000 "CompressedBitsPerPixel", | 2012 "CompressedBitsPerPixel", |
2001 "ExposureTime", | 2013 "ExposureTime", |
2002 "FNumber", | 2014 "FNumber", |
2003 "ShutterSpeedValue", // SRATIONAL | 2015 "ShutterSpeedValue", // SRATIONAL |
2028 { | 2040 { |
2029 // The story here is the same as with Exif. | 2041 // The story here is the same as with Exif. |
2030 // See Section 4.6.6, table 15 on page 68 of Exif specs | 2042 // See Section 4.6.6, table 15 on page 68 of Exif specs |
2031 // version 2.3 (CIPA DC- 008-Translation- 2010) | 2043 // version 2.3 (CIPA DC- 008-Translation- 2010) |
2032 | 2044 |
2033 static const char *gps_str_fields[] = { | 2045 static const char *gps_str_fields[] = |
2046 { | |
2034 "GPSLatitudeRef", | 2047 "GPSLatitudeRef", |
2035 "GPSLongitudeRef", | 2048 "GPSLongitudeRef", |
2036 "GPSAltitudeRef", | 2049 "GPSAltitudeRef", |
2037 "GPSSatellites", | 2050 "GPSSatellites", |
2038 "GPSStatus", | 2051 "GPSStatus", |
2051 static const string_vector gps_str (gps_str_fields); | 2064 static const string_vector gps_str (gps_str_fields); |
2052 static const octave_idx_type n_gps_str = gps_str.numel (); | 2065 static const octave_idx_type n_gps_str = gps_str.numel (); |
2053 for (octave_idx_type field = 0; field < n_gps_str; field++) | 2066 for (octave_idx_type field = 0; field < n_gps_str; field++) |
2054 fill_exif (gps, cimg, gps_str[field]); | 2067 fill_exif (gps, cimg, gps_str[field]); |
2055 | 2068 |
2056 static const char *gps_int_fields[] = { | 2069 static const char *gps_int_fields[] = |
2070 { | |
2057 "GPSDifferential", | 2071 "GPSDifferential", |
2058 0 | 2072 0 |
2059 }; | 2073 }; |
2060 static const string_vector gps_int (gps_int_fields); | 2074 static const string_vector gps_int (gps_int_fields); |
2061 static const octave_idx_type n_gps_int = gps_int.numel (); | 2075 static const octave_idx_type n_gps_int = gps_int.numel (); |
2062 for (octave_idx_type field = 0; field < n_gps_int; field++) | 2076 for (octave_idx_type field = 0; field < n_gps_int; field++) |
2063 fill_exif_ints (gps, cimg, gps_int[field]); | 2077 fill_exif_ints (gps, cimg, gps_int[field]); |
2064 | 2078 |
2065 static const char *gps_float_fields[] = { | 2079 static const char *gps_float_fields[] = |
2080 { | |
2066 "GPSAltitude", | 2081 "GPSAltitude", |
2067 "GPSDOP", | 2082 "GPSDOP", |
2068 "GPSSpeed", | 2083 "GPSSpeed", |
2069 "GPSTrack", | 2084 "GPSTrack", |
2070 "GPSImgDirection", | 2085 "GPSImgDirection", |
2115 ## No test needed for internal helper function. | 2130 ## No test needed for internal helper function. |
2116 %!assert (1) | 2131 %!assert (1) |
2117 */ | 2132 */ |
2118 | 2133 |
2119 DEFUN_DLD (__magick_formats__, args, , | 2134 DEFUN_DLD (__magick_formats__, args, , |
2120 "-*- texinfo -*-\n\ | 2135 "-*- texinfo -*-\n\ |
2121 @deftypefn {Loadable Function} {} __magick_imformats__ (@var{formats})\n\ | 2136 @deftypefn {Loadable Function} {} __magick_imformats__ (@var{formats})\n\ |
2122 Fill formats info with GraphicsMagick CoderInfo.\n\ | 2137 Fill formats info with GraphicsMagick CoderInfo.\n\ |
2123 \n\ | 2138 \n\ |
2124 @seealso{imfinfo, imformats, imread, imwrite}\n\ | 2139 @seealso{imfinfo, imformats, imread, imwrite}\n\ |
2125 @end deftypefn") | 2140 @end deftypefn") |