Fix crash when alpha-blending subtitles onto YUV420 images.
[dcpomatic.git] / src / lib / image.cc
index b82cc607249965cfbd8753c48e1421440614588b..03a4d96b4848da8a133828c144195b76033d396c 100644 (file)
@@ -1035,3 +1035,13 @@ Image::fade (float f)
                throw PixelFormatError ("fade()", _pixel_format);
        }
 }
+
+shared_ptr<Image>
+Image::ensure_aligned (shared_ptr<Image> image)
+{
+       if (image->aligned()) {
+               return image;
+       }
+
+       return shared_ptr<Image> (new Image (image, true));
+}