Skip to content

Commit

Permalink
Update gray color checker
Browse files Browse the repository at this point in the history
  • Loading branch information
daleclack committed May 5, 2024
1 parent 943dfc8 commit ec7b44b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Gtk4/src/core/MainWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ static int get_gray_color(GdkPixbuf *pixbuf)
int red = 0, green = 0, blue = 0;

// Calculate the color of image of 20x20 pixels
for (int i = 0; i < 20; i++)
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 20; j++)
for (int j = 0; j < 10; j++)
{
guchar *p = pixels + j * rowstride + i * n_channels;
red += p[0];
green += p[1];
blue += p[2];
}
}
red /= 400;
green /= 400;
blue /= 400;
red /= 100;
green /= 100;
blue /= 100;

// Calculate the gray number from the pixels
int gray = (red * 299 + green * 587 + blue * 114 + 500) / 1000;
Expand Down

0 comments on commit ec7b44b

Please sign in to comment.