Skip to content

Commit

Permalink
fix: remove c-style casts
Browse files Browse the repository at this point in the history
  • Loading branch information
realstealthninja committed Aug 20, 2024
1 parent e3c5ea5 commit 00bae08
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Image::render() {
exit(-1);
}
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
resize(image, image, cv::Size((int) w.ws_col, (int) w.ws_row), cv::INTER_LINEAR);
resize(image, image, cv::Size(static_cast<int>(w.ws_col), static_cast<int>(w.ws_row)), cv::INTER_LINEAR);

if(get_type() == EncodeType::GSCALE)
cvtColor(image, image, cv::COLOR_BGR2GRAY);
Expand Down
6 changes: 3 additions & 3 deletions src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::vector<std::string> array_to_ascii(cv::Mat& material, EncodeType encodeType
for (int i{0}; i < material.rows; i++) {
std::string line;
for (int j{0}; j < material.cols; j++) {
int pixel = (int)material.at<uchar>(i,j);
int pixel = static_cast<int>(material.at<uchar>(i,j));
if (encodeType == RGB){
int red = static_cast<int> (colors[2].at<uchar>(i,j));
int green = static_cast<int> (colors[1].at<uchar>(i,j));
Expand Down Expand Up @@ -121,14 +121,14 @@ void render_video(const char* path, EncodeType encodeType = EncodeType::GSCALE)

if (frame.empty()) break;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
resize(frame, frame, cv::Size((int) w.ws_col, (int)w.ws_row), cv::INTER_LINEAR);
resize(frame, frame, cv::Size(static_cast<int>(w.ws_col), static_cast<int>(w.ws_row)), cv::INTER_LINEAR);
if(encodeType == GSCALE)
cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);

std::vector<std::string> imageChar = array_to_ascii(frame, encodeType);

write(imageChar);
std::this_thread::sleep_for(std::chrono::milliseconds((int)displayRate));
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(displayRate)));
}

video.release();
Expand Down
4 changes: 2 additions & 2 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void Video::render() {

ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);

cv::resize(frame, frame, cv::Size((int) w.ws_col, (int)w.ws_row), cv::INTER_LINEAR);
cv::resize(frame, frame, cv::Size(static_cast<int>(w.ws_col), static_cast<int>(w.ws_row)), cv::INTER_LINEAR);

if(get_type() == GSCALE) {
cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);
Expand All @@ -41,7 +41,7 @@ void Video::render() {
set_art(array_to_ascii(frame, get_type()));
output();

std::this_thread::sleep_for(std::chrono::milliseconds((int)display_rate));
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(display_rate)));
}

video.release();
Expand Down

0 comments on commit 00bae08

Please sign in to comment.