Whitespace.
[dcpomatic.git] / src / lib / image.cc
index 722ff5d3ceff24509edeb49bb21ca9c575148abb..c11bcbb8d5b7c8076e71446ffa77659c921e5386 100644 (file)
@@ -45,6 +45,7 @@ extern "C" {
 
 using std::string;
 using std::min;
+using std::cout;
 using boost::shared_ptr;
 using libdcp::Size;
 
@@ -213,7 +214,11 @@ Image::crop (Crop crop, bool aligned) const
 
        for (int c = 0; c < components(); ++c) {
                int const crop_left_in_bytes = bytes_per_pixel(c) * crop.left;
-               int const cropped_width_in_bytes = bytes_per_pixel(c) * cropped_size.width;
+               /* bytes_per_pixel() could be a fraction; in this case the stride will be rounded
+                  up, and we need to make sure that we copy over the width (up to the stride)
+                  rather than short of the width; hence the ceil() here.
+               */
+               int const cropped_width_in_bytes = ceil (bytes_per_pixel(c) * cropped_size.width);
 
                /* Start of the source line, cropped from the top but not the left */
                uint8_t* in_p = data()[c] + (crop.top / out->line_factor(c)) * stride()[c];
@@ -331,7 +336,7 @@ Image::make_black ()
 }
 
 void
-Image::alpha_blend (shared_ptr<const Image> other, Position position)
+Image::alpha_blend (shared_ptr<const Image> other, Position<int> position)
 {
        /* Only implemented for RGBA onto RGB24 so far */
        assert (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGBA);
@@ -367,7 +372,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position position)
 }
 
 void
-Image::copy (shared_ptr<const Image> other, Position position)
+Image::copy (shared_ptr<const Image> other, Position<int> position)
 {
        /* Only implemented for RGB24 onto RGB24 so far */
        assert (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGB24);