Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
gtk
Commits
c3d99649
Commit
c3d99649
authored
Jun 29, 2017
by
Arnaud Blanchard
Browse files
Add management og YUYV
parent
31aeb6bf
Changes
1
Show whitespace changes
Inline
Side-by-side
o_gtk_image/src/image_display.cpp
View file @
c3d99649
...
...
@@ -159,7 +159,7 @@ gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
values
=
(
uint32_t
*
)
image_buffer
;
if
(
channel
->
type
==
'
UIN8
'
)
FOR_INV
(
i
,
channel
->
size
)
values
[
i
]
=
color_map
[
channel
->
uchars
[
i
]];
else
if
(
channel
->
type
==
'
FL32
'
)
FOR_INV
(
i
,
channel
->
size
/
sizeof
(
float
))
values
[
i
]
=
color_map
[
CLIP_UCHAR
(
channel
->
floats
[
i
]
*
256
-
0.5
f
)];
else
EXIT_ON_ARRAY_ERROR
(
channel
,
"Type not
a
managed"
);
else
EXIT_ON_ARRAY_ERROR
(
channel
,
"Type not managed"
);
gtk_image_set_from_surface
(
image
,
image_surface
);
gdk_window_get_device_position
(
gtk_widget_get_window
(
GTK_WIDGET
(
image
)),
pointer_device
,
&
x
,
&
y
,
NULL
);
...
...
@@ -314,7 +314,7 @@ gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
// 4:2:2
gboolean
update_YUYV_image
(
GtkImage
*
image
,
GdkFrameClock
*
frame_clock
,
blc_channel
*
channel
)
gboolean
update_YUYV_image
(
GtkImage
*
image
,
GdkFrameClock
*
frame_clock
,
void
*
)
{
int
i
,
j
;
uchar
*
data
=
(
uchar
*
)
channel
->
data
;
...
...
@@ -325,6 +325,7 @@ gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
pixels
=
(
uint32_t
*
)
image_buffer
;
if
(
blc_command_loop_start
()
==
0
)
exit
(
0
);
i
=
0
;
while
(
i
!=
(
int
)
channel
->
size
)
{
...
...
@@ -339,6 +340,8 @@ gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
pixels
[
1
]
=
RGBA_from_YUYV
[
j
];
pixels
+=
2
;
}
iterations
++
;
blc_command_loop_end
();
gtk_image_set_from_surface
(
image
,
image_surface
);
...
...
@@ -474,6 +477,33 @@ gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer pointer_
gtk_statusbar_push
(
GTK_STATUSBAR
(
pointer_statusbar
),
0
,
text
);
}
break
;
case
'
YUYV
'
:
for
(
i
=
channel
->
size
-
2
;
i
!=-
1
;
i
-=
2
)
histogram
[
channel
->
uchars
[
i
]]
++
;
for
(
i
=
channel
->
size
-
1
;
i
!=-
2
;
i
-=
4
)
histogram1
[
channel
->
uchars
[
i
]]
++
;
for
(
i
=
channel
->
size
-
3
;
i
!=-
4
;
i
-=
4
)
histogram2
[
channel
->
uchars
[
i
]]
++
;
FOR_INV
(
i
,
256
)
{
max
=
MAX
(
histogram
[
i
],
max
);
max1
=
MAX
(
histogram1
[
i
],
max1
);
max2
=
MAX
(
histogram2
[
i
],
max2
);
}
draw_histogram
(
histogram_data
,
127
,
histogram
,
gray_colors
,
max
);
draw_histogram
(
histogram_data
+
256
*
128
,
63
,
histogram1
,
u_colors
,
max1
);
draw_histogram
(
histogram_data
+
256
*
192
,
63
,
histogram2
,
v_colors
,
max2
);
if
(
y
>=
0
&&
y
<
256
&&
x
>=
0
&&
x
<
256
)
{
if
(
y
<
128
)
SPRINTF
(
text
,
"Y[%d]=%f.2%%"
,
x
,
histogram
[
x
]
*
100
*
2
/
(
float
)
channel
->
size
);
else
if
(
y
<
192
)
SPRINTF
(
text
,
"U[%d]=%.2f%%"
,
x
,
histogram1
[
x
]
*
100
*
4
/
(
float
)
channel
->
size
);
else
SPRINTF
(
text
,
"V[%d]=%.2f%%"
,
x
,
histogram2
[
x
]
*
100
*
4
/
(
float
)
channel
->
size
);
gtk_statusbar_push
(
GTK_STATUSBAR
(
pointer_statusbar
),
0
,
text
);
}
break
;
case
'
yuv2
'
:
for
(
i
=
channel
->
size
-
1
;
i
!=-
1
;
i
-=
2
)
histogram
[
channel
->
uchars
[
i
]]
++
;
...
...
@@ -690,7 +720,6 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
char
label_text
[
NAME_MAX
+
1
];
uint32_t
type_string
,
format_string
;
channel
=
tmp_channel
;
toolbar
=
gtk_toolbar_new
();
general_statusbar
=
gtk_statusbar_new
();
...
...
@@ -739,16 +768,15 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
image_buffer = MANY_ALLOCATIONS(width*height*3, uchar);
pixbuf = gdk_pixbuf_new_from_data( image_buffer, GDK_COLORSPACE_RGB, 0, 8, width, height, width * 3, NULL, NULL);
image = gtk_image_new_from_pixbuf(pixbuf);
gtk_widget_add_tick_callback(image, (GtkTickCallback) update_JPEG_image, channel, NULL);
gtk_widget_add_tick_callback(image, (GtkTickCallback) update_JPEG_image, channel, NULL);
*/
case
'
YUYV
'
:
width=channel->lengths[1];
height=channel->lengths[2];
image_buffer = MANY_ALLOCATIONS(width*height * 3, uchar); //In order to be sure that the rowstride will be 'gui.width * 3'
pixbuf = gdk_pixbuf_new_from_data(image_buffer, GDK_COLORSPACE_RGB, 0, 8, width, height, width * 3, NULL, NULL);
image = gtk_image_new_from_pixbuf(pixbuf);
pthread_create(&init_table_thread, NULL, create_RGB3_from_YUYV, image);
gtk_widget_add_tick_callback(GTK_WIDGET(image), (GtkTickCallback) update_YUYV_image, channel, NULL);
break;*/
width
=
channel
->
dims
[
1
].
length
;
height
=
channel
->
dims
[
2
].
length
;
image_buffer
=
MANY_ALLOCATIONS
(
width
*
height
*
4
,
uchar
);
//In order to be sure that the rowstride will be 'gui.width * 3'
image_surface
=
cairo_image_surface_create_for_data
(
image_buffer
,
CAIRO_FORMAT_RGB24
,
width
,
height
,
width
*
4
);
image
=
gtk_image_new_from_surface
(
image_surface
);
gtk_widget_add_tick_callback
(
GTK_WIDGET
(
image
),
(
GtkTickCallback
)
update_YUYV_image
,
pointer_statusbar
,
NULL
);
break
;
case
'
yuv2
'
:
case
'
UYVY
'
:
pthread_create
(
&
init_table_thread
,
NULL
,
create_RGBA_from_YUYV
,
image
);
width
=
channel
->
dims
[
1
].
length
;
...
...
@@ -756,8 +784,6 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
image_buffer
=
MANY_ALLOCATIONS
(
width
*
height
*
4
,
uchar
);
image_surface
=
cairo_image_surface_create_for_data
(
image_buffer
,
CAIRO_FORMAT_RGB24
,
width
,
height
,
width
*
4
);
image
=
gtk_image_new_from_surface
(
image_surface
);
// if (interactive_mode) pthread_create(&thread, NULL, refresh_yuv2_cb, image);
//g_timeout_add(0, refresh_yuv2_cb, image); //To be improved
gtk_widget_add_tick_callback
(
GTK_WIDGET
(
image
),
(
GtkTickCallback
)
update_yuv2_image
,
pointer_statusbar
,
NULL
);
break
;
default:
return
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment