mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-17 06:19:54 +02:00
utils/rescaler: add WebPRescalerGetScaledDimensions
+ use it in WebPPictureRescale() Change-Id: I491bea8cd56f0eb1ac8bf0829b9f36c77804219a
This commit is contained in:
@ -211,16 +211,10 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) {
|
||||
if (pic == NULL) return 0;
|
||||
prev_width = pic->width;
|
||||
prev_height = pic->height;
|
||||
// if width is unspecified, scale original proportionally to height ratio.
|
||||
if (width == 0) {
|
||||
width = (prev_width * height + prev_height / 2) / prev_height;
|
||||
if (!WebPRescalerGetScaledDimensions(
|
||||
prev_width, prev_height, &width, &height)) {
|
||||
return 0;
|
||||
}
|
||||
// if height is unspecified, scale original proportionally to width ratio.
|
||||
if (height == 0) {
|
||||
height = (prev_height * width + prev_width / 2) / prev_width;
|
||||
}
|
||||
// Check if the overall dimensions still make sense.
|
||||
if (width <= 0 || height <= 0) return 0;
|
||||
|
||||
PictureGrabSpecs(pic, &tmp);
|
||||
tmp.width = width;
|
||||
|
Reference in New Issue
Block a user