public bool TryGetBitmapTransform(string optionValue, IEnumerable<KeyValuePair<string, string>> settings, out Func<BitmapSource, BitmapSource> bitmapTransformerFunc)
{
int maxHeight;
if (!int.TryParse(optionValue, out maxHeight))
{
bitmapTransformerFunc = null;
return false;
}
bitmapTransformerFunc = (sourceBitmap =>
{
if (sourceBitmap.PixelHeight <= maxHeight)
{
return sourceBitmap;
}
var scale = maxHeight / (double)sourceBitmap.PixelHeight;
return new TransformedBitmap(sourceBitmap, new ScaleTransform(scale, scale));
});
return true;
}