[Tizen] Fix coverity issue : Convert uint32_t to float first, then minus operate 80/319280/1 accepted/tizen/9.0/unified/20250210.170331
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 6 Feb 2025 05:59:42 +0000 (14:59 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 7 Feb 2025 03:37:05 +0000 (12:37 +0900)
Since it is possible that widthIn is zero, we should consider
the code with negavie cases.

Change-Id: I0c71d6336b2b415bc2af731ff738e79ac5fef9db
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/imaging/common/image-operations.cpp

index 35208cc2913f4f542aa22b1076d5fa7a0d0b25ed..0ad6a75066cb306328baf29d47c39d45af885ce1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -2658,7 +2658,7 @@ void RotateByShear(const uint8_t* const pixelsIn,
   }
 
   // Variable skew offset
-  float offset = angleSinus * ((angleSinus > 0.f) ? static_cast<float>(widthIn - 1u) : -(static_cast<float>(widthIn) - static_cast<float>(widthOut)));
+  float offset = angleSinus * ((angleSinus > 0.f) ? (static_cast<float>(widthIn) - 1.0f) : -(static_cast<float>(widthIn) - static_cast<float>(widthOut)));
 
   uint32_t column = 0u;
   for(column = 0u; column < widthOut; ++column, offset -= angleSinus)
@@ -2695,7 +2695,7 @@ void RotateByShear(const uint8_t* const pixelsIn,
     return;
   }
 
-  offset = (angleSinus >= 0.f) ? -angleSinus * angleTangent * static_cast<float>(widthIn - 1u) : angleTangent * (static_cast<float>(widthIn - 1u) * -angleSinus + (1.f - static_cast<float>(heightOut)));
+  offset = (angleSinus >= 0.f) ? -angleSinus * angleTangent * (static_cast<float>(widthIn) - 1.0f) : angleTangent * ((static_cast<float>(widthIn) - 1.0f) * -angleSinus + (1.f - static_cast<float>(heightOut)));
 
   for(uint32_t y = 0u; y < heightOut; ++y, offset += angleTangent)
   {