2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <Magick++/Image.h>
22 #include "imagemagick_decoder.h"
23 #include "film_state.h"
27 using namespace boost;
29 ImageMagickDecoder::ImageMagickDecoder (
30 boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Job* j, Log* l, bool minimal, bool ignore_length)
31 : Decoder (s, o, j, l, minimal, ignore_length)
34 _magick_image = new Magick::Image (_fs->content_path ());
38 ImageMagickDecoder::native_size () const
40 return Size (_magick_image->columns(), _magick_image->rows());
44 ImageMagickDecoder::do_pass ()
50 Size size = native_size ();
51 RGBFrameImage image (size);
53 uint8_t* p = image.data()[0];
54 for (int y = 0; y < size.height; ++y) {
55 for (int x = 0; x < size.width; ++x) {
56 Magick::Color c = _magick_image->pixelColor (x, y);
57 *p++ = c.redQuantum() * 255 / MaxRGB;
58 *p++ = c.greenQuantum() * 255 / MaxRGB;
59 *p++ = c.blueQuantum() * 255 / MaxRGB;
64 process_video (image.frame (), shared_ptr<Subtitle> ());
71 ImageMagickDecoder::pixel_format () const