浏览代码

ColorI::fromLinear fix

rextimmy 8 年之前
父节点
当前提交
1f477914aa
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      Engine/source/core/color.h

+ 4 - 4
Engine/source/core/color.h

@@ -884,10 +884,10 @@ inline ColorI LinearColorF::toColorI(const bool keepAsLinear)
 inline ColorI ColorI::fromLinear()
 {
    //manually create LinearColorF, otherwise it will try and convert to linear first
-   LinearColorF linearColor = LinearColorF(F32(red) * 255.0f + 0.5f,
-                                           F32(red) * 255.0f + 0.5f,
-                                           F32(red) * 255.0f + 0.5f,
-                                           F32(alpha) * 255.0f + 0.5f);
+   LinearColorF linearColor = LinearColorF(F32(red) * gOneOver255,
+                                           F32(green) * gOneOver255,
+                                           F32(blue) * gOneOver255,
+                                           F32(alpha) * gOneOver255);
    //convert back to srgb
    return linearColor.toColorI();
 }