浏览代码

Fixed overflow for high values.

0xffff would accidentally round to 0x10000.
rmitton 10 年之前
父节点
当前提交
608cbec1f5
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      stb_image.h

+ 1 - 1
stb_image.h

@@ -5195,7 +5195,7 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
             // Read the data.
             if (bitdepth == 16) {
                for (i = 0; i < pixelCount; i++, p += 4)
-                  *p = (stbi__get16le(s) + 127) >> 8;
+                  *p = stbi__get16le(s) * 255 / 65535;
             } else {
                for (i = 0; i < pixelCount; i++, p += 4)
                   *p = stbi__get8(s);