mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 14:18:21 +01:00
dec: allow 0 as a scaling dimension
this allows scaling to a particular width/height while preserving the source aspect ratio using WebPRescalerGetScaledDimensions(). Change-Id: I77b11528753290c1e9bb942ac761c215ccfb8701
This commit is contained in:
parent
b918724280
commit
24a9693223
@ -181,11 +181,14 @@ VP8StatusCode WebPAllocateDecBuffer(int w, int h,
|
||||
h = ch;
|
||||
}
|
||||
if (options->use_scaling) {
|
||||
if (options->scaled_width <= 0 || options->scaled_height <= 0) {
|
||||
int scaled_width = options->scaled_width;
|
||||
int scaled_height = options->scaled_height;
|
||||
if (!WebPRescalerGetScaledDimensions(
|
||||
w, h, &scaled_width, &scaled_height)) {
|
||||
return VP8_STATUS_INVALID_PARAM;
|
||||
}
|
||||
w = options->scaled_width;
|
||||
h = options->scaled_height;
|
||||
w = scaled_width;
|
||||
h = scaled_height;
|
||||
}
|
||||
}
|
||||
out->width = w;
|
||||
|
@ -806,11 +806,13 @@ int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
|
||||
// Scaling
|
||||
io->use_scaling = (options != NULL) && (options->use_scaling > 0);
|
||||
if (io->use_scaling) {
|
||||
if (options->scaled_width <= 0 || options->scaled_height <= 0) {
|
||||
int scaled_width = options->scaled_width;
|
||||
int scaled_height = options->scaled_height;
|
||||
if (!WebPRescalerGetScaledDimensions(w, h, &scaled_width, &scaled_height)) {
|
||||
return 0;
|
||||
}
|
||||
io->scaled_width = options->scaled_width;
|
||||
io->scaled_height = options->scaled_height;
|
||||
io->scaled_width = scaled_width;
|
||||
io->scaled_height = scaled_height;
|
||||
}
|
||||
|
||||
// Filter
|
||||
|
Loading…
Reference in New Issue
Block a user