cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

pixel_buffer::ellipse can't be compiled in MSVC #664

Closed ventsin closed 2 years ago

ventsin commented 2 years ago

The method void pixel_buffer::ellipse(const nana::point& pt, float a, float b, const color& c) was added in commit bf26f622e382383969ce00c729b7ee30f6671f8b, and it breaks compilation under MSVC.

Compile log as follows:

[...]source\paint\pixel_buffer.cpp(1564,15): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1565,15): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1568,18): error C2398: Element '2': conversion from 'float' to 'int' requires a narrowing conversion 
[...]source\paint\pixel_buffer.cpp(1568,18): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1569,18): error C2398: Element '2': conversion from 'float' to 'int' requires a narrowing conversion 
[...]source\paint\pixel_buffer.cpp(1569,18): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1572,12): warning C4244: '=': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1574,20): warning C4244: '=': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1599,15): error C2398: Element '1': conversion from 'float' to 'int' requires a narrowing conversion 
[...]source\paint\pixel_buffer.cpp(1599,15): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1600,15): error C2398: Element '1': conversion from 'float' to 'int' requires a narrowing conversion 
[...]source\paint\pixel_buffer.cpp(1600,15): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1602,12): warning C4244: '=': conversion from 'float' to 'int', possible loss of data 
[...]source\paint\pixel_buffer.cpp(1604,20): warning C4244: '=': conversion from 'float' to 'int', possible loss of data

Basically, a and b need to be rounded before being added to x and y, respectively.