-/** Scale this image to a given size and convert it to RGB.
- * @param out_size Output image size in pixels.
- * @param scaler Scaler to use.
- */
-shared_ptr<Image>
-Image::scale_and_convert_to_rgb (libdcp::Size out_size, Scaler const * scaler, bool result_aligned) const
-{
- assert (scaler);
- /* Empirical testing suggests that sws_scale() will crash if
- the input image is not aligned.
- */
- assert (aligned ());
-
- shared_ptr<Image> rgb (new SimpleImage (PIX_FMT_RGB24, out_size, result_aligned));
-
- struct SwsContext* scale_context = sws_getContext (
- size().width, size().height, pixel_format(),
- out_size.width, out_size.height, PIX_FMT_RGB24,
- scaler->ffmpeg_id (), 0, 0, 0
- );
-
- /* Scale and convert to RGB from whatever its currently in (which may be RGB) */
- sws_scale (
- scale_context,
- data(), stride(),
- 0, size().height,
- rgb->data(), rgb->stride()
- );
-
- sws_freeContext (scale_context);
-
- return rgb;
-}
-