diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-11-08 20:13:59 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-11-08 20:13:59 +0300 |
commit | e59ebfef3c583985553e78492cf8cd07bbe7648e (patch) | |
tree | 35f31c3b592f40885baf8d8b078844c92bfbabe7 /source/blender/imbuf/intern/util_gpu.c | |
parent | fe7088c99ff084f7218ab20136d49eb1a1dccd0b (diff) | |
parent | 4c182aef7ce0e8c26dd2b85c1fa2cd45c2ef64ea (diff) |
Merge branch 'master' into temp-sculpt-brush-channeltemp-sculpt-brush-channel
Diffstat (limited to 'source/blender/imbuf/intern/util_gpu.c')
-rw-r--r-- | source/blender/imbuf/intern/util_gpu.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index 5ed6b2b9843..35cdefbaaeb 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -301,6 +301,16 @@ GPUTexture *IMB_create_gpu_texture(const char *name, int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]); + /* Correct the smaller size to maintain the original aspect ratio of the image. */ + if (do_rescale && ibuf->x != ibuf->y) { + if (size[0] > size[1]) { + size[1] = (int)(ibuf->y * ((float)size[0] / ibuf->x)); + } + else { + size[0] = (int)(ibuf->x * ((float)size[1] / ibuf->y)); + } + } + #ifdef WITH_DDS if (ibuf->ftype == IMB_FTYPE_DDS) { eGPUTextureFormat compressed_format; |