Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new test for find bright pixels (error pixels) of a lcd screen. #5

Merged
merged 3 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bin_PROGRAMS = screentest

screentest_SOURCES = main.c main.h callbacks.c callbacks.h test_basic.c \
test_blink.c test_grid.c test_horizontal.c test_text.c \
test_vertical.c test_lcdalign.c gettext.h
test_vertical.c test_lcdalign.c test_bright_pixels.c gettext.h

screentest_LDADD = $(GLIB_LIBS) $(GTK_LIBS)

Expand Down
10 changes: 10 additions & 0 deletions screentest.ui
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@
<signal name="activate" handler="on_mode_change"/>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="bright_pixels">
<property name="visible">True</property>
<property name="label" translatable="yes">Bright Pixels</property>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if "Solid color" would be the better label? Not sure about this myself 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Name is no matter. "Solid Color Cycle RGBWB". What ever ;)

<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">basic</property>
<signal name="activate" handler="on_mode_change"/>
</object>
</child>
</object>
</child>
</object>
Expand Down
22 changes: 13 additions & 9 deletions test_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* https://tobix.github.io/screentest/
* Copyright (C) 2001 Jan "Yenya" Kasprzak <kas@fi.muni.cz>
* Copyright (C) 2006-2017 Tobias Gruetzmacher <tobias-screentest@23.gs>
* Copyright (C) 2021 Apr Thorsten Kattanek <thorsten.kattanek@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
Expand Down Expand Up @@ -67,11 +68,12 @@ static void basic_draw(GtkWidget * widget)
gint w, h;
gint i, b, d;
gint maxwidth, maxheight;
gint widths[6];
gint widths[7];
static gchar *text[] = {
"Screentest v" VERSION,
"(C) 2001 Jan \"Yenya\" Kasprzak <kas@fi.muni.cz>",
"(C) 2006-2017 Tobias Gruetzmacher <tobias-screentest@23.gs>",
"(C) 2021 Apr Thorsten Kattanek <thorsten.kattanek@gmx.de>",
N_("Left Button - param cycle, if any"),
N_("Middle Button - color cycle"),
N_("Right Button - menu"),
Expand All @@ -89,14 +91,14 @@ static void basic_draw(GtkWidget * widget)
d = h / 4;

maxheight = 0;
for (i = 0; i < 5; i++) {
for (i = 0; i < 7; i++) {
int x = gdk_string_height(font, gettext(text[i]));
if (x > maxheight)
maxheight = x;
}

maxwidth = 0;
for (i = 0; i < 6; i++) {
for (i = 0; i < 7; i++) {
widths[i] = gdk_string_width(font, gettext(text[i]));
if (widths[i] > maxwidth)
maxwidth = widths[i];
Expand All @@ -105,13 +107,13 @@ static void basic_draw(GtkWidget * widget)
maxwidth += 20;
maxheight = 3 * maxheight / 2;
gdk_draw_rectangle(win, gc, FALSE, (w - maxwidth) / 2,
d / 2 - 2 * maxheight, maxwidth, 4 * maxheight);
d / 2 - 2 * maxheight, maxwidth, 5 * maxheight);
gdk_draw_rectangle(win, gc, FALSE, (w - maxwidth) / 2,
h - d / 2 - 2 * maxheight, maxwidth,
4 * maxheight);
gdk_draw_rectangle(win, backgc, TRUE, (w - maxwidth) / 2 + 1,
d / 2 - 2 * maxheight + 1, maxwidth - 1,
4 * maxheight - 1);
5 * maxheight - 1);
gdk_draw_rectangle(win, backgc, TRUE, (w - maxwidth) / 2 + 1,
h - d / 2 - 2 * maxheight + 1, maxwidth - 1,
4 * maxheight - 1);
Expand All @@ -122,13 +124,15 @@ static void basic_draw(GtkWidget * widget)
d / 2 + maxheight / 3, gettext(text[1]));
gdk_draw_string(win, font, gc, (w - widths[2]) / 2,
d / 2 + 4 * maxheight / 3, gettext(text[2]));

gdk_draw_string(win, font, gc, (w - widths[3]) / 2,
h - d / 2 - 2 * maxheight / 3, gettext(text[3]));
d / 2 + 7 * maxheight / 3, gettext(text[3]));

gdk_draw_string(win, font, gc, (w - widths[4]) / 2,
h - d / 2 + maxheight / 3, gettext(text[4]));
h - d / 2 - 2 * maxheight / 3, gettext(text[4]));
gdk_draw_string(win, font, gc, (w - widths[5]) / 2,
h - d / 2 + 4 * maxheight / 3, gettext(text[5]));
h - d / 2 + maxheight / 3, gettext(text[5]));
gdk_draw_string(win, font, gc, (w - widths[6]) / 2,
h - d / 2 + 4 * maxheight / 3, gettext(text[6]));

b = 7 * d / 4;
draw_boxes(win, fgcolors, COLOR_MAX, (w - b) / 2,
Expand Down
63 changes: 63 additions & 0 deletions test_bright_pixels.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Screentest - CRT/LCD monitor testing utility.
* https://tobix.github.io/screentest/
* Copyright (C) 2011-2017 Tobias Gruetzmacher <tobias-screentest@23.gs>
* Copyright (C) 2021 Apr Thorsten Kattanek <thorsten.kattanek@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdio.h>
#include <gtk/gtk.h>

#include "callbacks.h"

#define COLOR_COUNT 5
static const int color_cycle[COLOR_COUNT]={COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_WHITE,COLOR_BLACK};
static int current_color_idx;

static void bright_pixels_init(G_GNUC_UNUSED GtkWidget * widget)
{
current_color_idx = 0;
}

static void bright_pixels_cycle(G_GNUC_UNUSED GtkWidget * widget)
{
current_color_idx++;
if(current_color_idx == COLOR_COUNT)
current_color_idx = 0;
}

static void bright_pixels_draw(GtkWidget * widget)
{
GdkWindow *win = gtk_widget_get_window(widget);
gint w, h;

gdk_drawable_get_size(win, &w, &h);
gdk_gc_set_rgb_fg_color(gc, &fgcolors[color_cycle[current_color_idx]]);
gdk_draw_rectangle(win, gc, 1, 0, 0, w, h);

gdk_gc_set_rgb_fg_color(gc, &fgcolors[COLOR_WHITE]);
}

G_MODULE_EXPORT struct test_ops bright_pixels_ops = {
.init = bright_pixels_init,
.draw = bright_pixels_draw,
.cycle = bright_pixels_cycle,
.close = NULL
};