Skip to content

Commit

Permalink
bug : fix colors (red and blue were swapped) (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkwalExe authored Aug 14, 2022
1 parent cb416c2 commit 3ec0b49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char *argv[])
switch (cmd)
{
case version:
std::cout << PURPLE << "ascii-video-player => " << YELLOW << "0.2.0" << std::endl;
std::cout << PURPLE << "ascii-video-player => " << YELLOW << "0.2.1" << std::endl;
break;
case help:
cout << WHITE << "video-ascii-player" << RESET << endl;
Expand Down
4 changes: 2 additions & 2 deletions src/play_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ void display_frame_with_colors(Mat frame, bool blocks, bool color_background)
if (blocks)
{
cout << "\x1b[48;2;"
<< (int)pixel_color[0] << ";" << (int)pixel_color[1] << ";" << (int)pixel_color[2]
<< (int)pixel_color[2] << ";" << (int)pixel_color[1] << ";" << (int)pixel_color[0]
<< "m" << " " << "\x1b[0m";
}
else {
int pixel_gray_value = (pixel_color[0] + pixel_color[1] + pixel_color[2]) / 3;
int char_index = chars_array_len * pixel_gray_value / 255;

cout << "\x1b[" << (color_background ? "48" : "38") << ";2;"
<< (int) pixel_color[0] << ";" << (int) pixel_color[1] << ";" << (int) pixel_color[2]
<< (int) pixel_color[2] << ";" << (int) pixel_color[1] << ";" << (int) pixel_color[0]
<< "m" << ASCII_CHARS[char_index] << "\x1b[0m";
}
}
Expand Down

0 comments on commit 3ec0b49

Please sign in to comment.