I have an image with a width of 888px and a height of 592px, with the aspect ratio of the width: height as 3: 2.
The following is an incorrect value of 1 due to integer calculation / truncation, both BitmapDecoder.PixelWidth and BitmapDecoder.PixelHeight are both uint (unsigned integer) and decoder below, which is a BitmapDecoder object.
double aspectRatio = decoder.PixelWidth / decoder.PixelHeight;
The following is the expected correct value of 1.5, but Visual Studio says "Cast is redundant", but why?
double aspectRatio = (double)decoder.PixelWidth / (double)decoder.PixelHeight;
source share