Commit f2ae40e2 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Remove dependnace on channel for c_gtk_image

Add parameter address and port
parent 0a444df0
......@@ -17,15 +17,16 @@ using namespace std;
float min_val, max_val;
const char *channel_name, *fullscreen_option, *keyboard_mode;
const char *channel_name, *fullscreen_option, *keyboard_mode, *address, *port_name;
GtkWidget *window;
GdkDisplay *main_display;
GdkDevice *pointer_device;
int interactive_mode=0;
GtkApplication *app;
blc_channel mouse_channel;
blc_channel input;
blc_array mouse_array;
blc_array input;
char const *input_name;
......@@ -61,20 +62,21 @@ void activate_cb(GApplication *app)
{
GtkWidget *display=nullptr;
GtkWidget *grid;
string title(string(address)+":"+string(port_name));
main_display = gdk_display_get_default ();
GdkDeviceManager *device_manager = gdk_display_get_device_manager (main_display);
pointer_device = gdk_device_manager_get_client_pointer (device_manager);
window=gtk_application_window_new(GTK_APPLICATION(app));
gtk_window_set_title(GTK_WINDOW(window), input.name);
gtk_window_set_title(GTK_WINDOW(window), title.c_str());
grid=gtk_grid_new();
// for(i=0; input_names[i]; i++){ This is for displaying multiple images
// input=new blc_channel(/*input_names[i]*/ input_name, BLC_CHANNEL_READ);
display=create_image_display(&input);
if (display==NULL) EXIT_ON_CHANNEL_ERROR(&input, "Format not managed.");
if (display==NULL) EXIT_ON_ARRAY_ERROR(&input, "Format not managed.");
gtk_widget_set_hexpand(display, 1);
gtk_widget_set_vexpand(display, 1);
gtk_container_add(GTK_CONTAINER(grid), display);
......@@ -99,11 +101,13 @@ int main(int argc, char *argv[])
blc_program_add_option(&max_str, 'M', "max", "FL32", "maximal value", nullptr);
blc_program_add_option(&fullscreen_option, 'F', "fullscreen", nullptr, "Set the window in fullscreen", nullptr);
blc_program_add_option(&g_debug, 'g', "g-fatal-warnings", nullptr, "Debug gtk.", nullptr);
blc_program_add_parameter(&address, "address", 1, "internet address", "localhost");
blc_program_add_parameter(&port_name, "port", 1, "port name", "31440");
blc_program_init(&argc, &argv, ask_quit);
blc_command_forward_blc_channels();
blc_array_tcp4_client input_client(&input, "127.0.0.1", "31440");
blc_array_tcp4_client input_client(&input, address, port_name);
input.allocate();
fprintf(stderr, "Connecté\n");
......@@ -123,7 +127,9 @@ int main(int argc, char *argv[])
thread input_thread([&input_client](){
while(1) input_client.read_data();
while(1) {
input_client.read_data();
}
});
gtk_disable_setlocale();
......@@ -133,6 +139,7 @@ int main(int argc, char *argv[])
status = g_application_run(G_APPLICATION(app), 0, nullptr);
g_object_unref(app);
input_thread.join();
return EXIT_SUCCESS;
}
......@@ -2,12 +2,12 @@
#define COMMON_H
#include <gtk/gtk.h>
#include <blc_channel.h>
#include <blc_core.h>
extern float min_val, max_val;
extern blc_channel *channel;
extern blc_array *array;
extern GtkWidget *legend;
extern u_int32_t false_colors[256];
......@@ -21,14 +21,14 @@ extern uint32_t *color_map;
extern GtkWidget *window, *paned;
extern GdkDevice *pointer_device;
extern blc_channel mouse_channel;
extern blc_array mouse_array;
extern char const *fullscreen_option;
void histogram_cb(GtkToolButton *toolbutton, gpointer pointer_statusbar );
GtkWidget *create_image_display(blc_channel *channel);
GtkWidget *create_image_display(blc_array *array);
#endif
......@@ -18,7 +18,7 @@ GdkDisplay *main_display;
GdkDevice *pointer_device;
int interactive_mode=0;
GtkApplication *app;
blc_channel mouse_channel;
blc_array mouse_array;
blc_channel input;
......@@ -68,6 +68,9 @@ void activate_cb(GApplication *app)
// for(i=0; input_names[i]; i++){ This is for displaying multiple images
// input=new blc_channel(/*input_names[i]*/ input_name, BLC_CHANNEL_READ);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
display=create_image_display(&input);
if (display==NULL) EXIT_ON_CHANNEL_ERROR(&input, "Format not managed.");
gtk_widget_set_hexpand(display, 1);
......
......@@ -43,11 +43,11 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
x*=sx;
y*=sy;
switch (channel->format){
switch (array->format){
case 'Y800':
switch (channel->type){
switch (array->type){
case 'UIN8':
FOR(i, channel->size) histogram[channel->uchars[i]]++;
FOR(i, array->size) histogram[array->uchars[i]]++;
FOR(i, 256) hist_max=MAX(histogram[i], hist_max);
FOR(i, 256)
......@@ -58,12 +58,12 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
}
if (y>=0 && y<256 && x >=0 && x<256)
{
SPRINTF(text, "Y[%d]=%f.2%%", x, histogram[x]*100/(float)channel->size);
SPRINTF(text, "Y[%d]=%f.2%%", x, histogram[x]*100/(float)array->size);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
break;
case 'FL32':
FOR(i, channel->total_length) histogram[(int)CLIP_UCHAR(((channel->floats[i]-min_val)/(max_val-min_val)*256+0.5))]++;
FOR(i, array->total_length) histogram[(int)CLIP_UCHAR(((array->floats[i]-min_val)/(max_val-min_val)*256+0.5))]++;
FOR(i, 256) hist_max=MAX(histogram[i], hist_max);
FOR(i, 256)
{
......@@ -73,18 +73,18 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
}
if (y>=0 && y<256 && x >=0 && x<256)
{
SPRINTF(text, "Y[%f]=%f.2%%", x*(max_val-min_val-0.5)/256+min_val, histogram[x]*100/(float)channel->total_length);
SPRINTF(text, "Y[%f]=%f.2%%", x*(max_val-min_val-0.5)/256+min_val, histogram[x]*100/(float)array->total_length);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
break;
default: EXIT_ON_ARRAY_ERROR( channel, "Type not managed for format 'Y800'. Only 'UIN8' is");
default: EXIT_ON_ARRAY_ERROR( array, "Type not managed for format 'Y800'. Only 'UIN8' is");
}
break;
case 'RGB3':
FOR_INV(i, channel->size/3){
histogram[channel->uchars[i*3]]++;
histogram1[channel->uchars[i*3+1]]++;
histogram2[channel->uchars[i*3+2]]++;
FOR_INV(i, array->size/3){
histogram[array->uchars[i*3]]++;
histogram1[array->uchars[i*3+1]]++;
histogram2[array->uchars[i*3+2]]++;
}
FOR_INV(i, 256)
......@@ -99,17 +99,17 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
if (y>=0 && y<256 && x >=0 && x<256)
{
if (y<85) SPRINTF(text, "R[%d]=%f.2%%", x, histogram[x]*100*2/(float)channel->size);
else if (y<170) SPRINTF(text, "G[%d]=%.2f%%", x, histogram1[x]*100*4/(float)channel->size);
else SPRINTF(text, "B[%d]=%.2f%%", x, histogram2[x]*100*4/(float)channel->size);
if (y<85) SPRINTF(text, "R[%d]=%f.2%%", x, histogram[x]*100*2/(float)array->size);
else if (y<170) SPRINTF(text, "G[%d]=%.2f%%", x, histogram1[x]*100*4/(float)array->size);
else SPRINTF(text, "B[%d]=%.2f%%", x, histogram2[x]*100*4/(float)array->size);
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(i=array->size-2;i!=-1;i-=2) histogram[array->uchars[i]]++;
for(i=array->size-1;i!=-2;i-=4) histogram1[array->uchars[i]]++;
for(i=array->size-3;i!=-4;i-=4) histogram2[array->uchars[i]]++;
FOR_INV(i, 256)
{
......@@ -124,16 +124,16 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
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);
if (y<128) SPRINTF(text, "Y[%d]=%f.2%%", x, histogram[x]*100*2/(float)array->size);
else if (y<192) SPRINTF(text, "U[%d]=%.2f%%", x, histogram1[x]*100*4/(float)array->size);
else SPRINTF(text, "V[%d]=%.2f%%", x, histogram2[x]*100*4/(float)array->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]]++;
for(i=channel->size-2;i!=-2;i-=4) histogram1[channel->uchars[i]]++;
for(i=channel->size-4;i!=-4;i-=4) histogram2[channel->uchars[i]]++;
for(i=array->size-1;i!=-1;i-=2) histogram[array->uchars[i]]++;
for(i=array->size-2;i!=-2;i-=4) histogram1[array->uchars[i]]++;
for(i=array->size-4;i!=-4;i-=4) histogram2[array->uchars[i]]++;
FOR_INV(i, 256)
{
......@@ -148,9 +148,9 @@ static gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer p
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);
if (y<128) SPRINTF(text, "Y[%d]=%f.2%%", x, histogram[x]*100*2/(float)array->size);
else if (y<192) SPRINTF(text, "U[%d]=%.2f%%", x, histogram1[x]*100*4/(float)array->size);
else SPRINTF(text, "V[%d]=%.2f%%", x, histogram2[x]*100*4/(float)array->size);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
......
......@@ -44,7 +44,7 @@ double zoom_in_factor=2, zoom_out_factor=0.5;
GtkWidget *legend=NULL;
static int width=0, height=0;
blc_channel *channel=NULL;
blc_array *array=NULL;
static int g_source_continue=G_SOURCE_CONTINUE;
......@@ -172,11 +172,11 @@ gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
if (blc_command_loop_start()){
values = (uint32_t*)image_buffer;
if (channel->type=='UIN8')
FOR(i, channel->size) values[i]=color_map[channel->uchars[i]];
else if (channel->type=='FL32')
FOR(i, channel->total_length) values[i]=color_map[CLIP_UCHAR((channel->floats[i]-min_val)*256*gain-0.5f)];
else EXIT_ON_ARRAY_ERROR(channel, "Type not managed");
if (array->type=='UIN8')
FOR(i, array->size) values[i]=color_map[array->uchars[i]];
else if (array->type=='FL32')
FOR(i, array->total_length) values[i]=color_map[CLIP_UCHAR((array->floats[i]-min_val)*256*gain-0.5f)];
else EXIT_ON_ARRAY_ERROR(array, "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);
......@@ -184,8 +184,8 @@ gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
i=x*sx;
j=y*sy;
if (i<width && j<height && i>=0 && j>=0){
if (channel->type=='UIN8') SPRINTF(text, "%4d,%4d: Y:%3d", i,j, channel->uchars[i+j*width]);
else if (channel->type=='FL32') SPRINTF(text, "%4d,%4d: Y:%.3f", i,j, channel->floats[i+j*width]);
if (array->type=='UIN8') SPRINTF(text, "%4d,%4d: Y:%3d", i,j, array->uchars[i+j*width]);
else if (array->type=='FL32') SPRINTF(text, "%4d,%4d: Y:%.3f", i,j, array->floats[i+j*width]);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
iterations++;
......@@ -205,10 +205,10 @@ gboolean update_RGB3_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(image)), pointer_device, &x, &y, NULL);
cairo_surface_get_device_scale(image_surface, &sx, &sy);
while(i!=channel->size){
image_buffer[j++]=channel->uchars[i+2];
image_buffer[j++]=channel->uchars[i+1];
image_buffer[j++]=channel->uchars[i];
while(i!=array->size){
image_buffer[j++]=array->uchars[i+2];
image_buffer[j++]=array->uchars[i+1];
image_buffer[j++]=array->uchars[i];
j++;
i+=3;
}
......@@ -217,16 +217,16 @@ gboolean update_RGB3_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
j=y*sy;
if (i<width && j<height && i>=0 && j>=0){
if (mouse_channel.fd!=-1)
if (mouse_array.dims!=nullptr)
{
mouse_channel.uints32[0]=i;
mouse_channel.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_channel.uints32[2]));
mouse_array.uints32[0]=i;
mouse_array.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_array.uints32[2]));
}
R=channel->uchars[i*4+j*width*3];
G=channel->uchars[i*4+j*width*3+1];
B=channel->uchars[i*4+j*width*3+2];
R=array->uchars[i*4+j*width*3];
G=array->uchars[i*4+j*width*3+1];
B=array->uchars[i*4+j*width*3+2];
SPRINTF(text, "%4d,%4d : R:%3d,G:%3d,B:%3d", i, j, R, G, B);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
......@@ -252,22 +252,22 @@ gboolean update_RGBA_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(image)), pointer_device, &x, &y, NULL);
cairo_surface_get_device_scale(image_surface, &sx, &sy);
FOR_INV(i, channel->size/4) ((uint32_t*)image_buffer)[i]=SWAP_RGBA_TO_CAIRO_ARGB32(channel->uints32[i]);
FOR_INV(i, array->size/4) ((uint32_t*)image_buffer)[i]=SWAP_RGBA_TO_CAIRO_ARGB32(array->uints32[i]);
i=x*sx;
j=y*sy;
if (i<width && j<height && i>=0 && j>=0){
if (mouse_channel.fd!=-1){
mouse_channel.uints32[0]=i;
mouse_channel.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_channel.uints32[2]));
if (mouse_array.dims!=nullptr){
mouse_array.uints32[0]=i;
mouse_array.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_array.uints32[2]));
}
R=channel->uchars[i*4+j*width*4];
G=channel->uchars[i*4+j*width*4+1];
B=channel->uchars[i*4+j*width*4+2];
A=channel->uchars[i*4+j*width*4+3];
R=array->uchars[i*4+j*width*4];
G=array->uchars[i*4+j*width*4+1];
B=array->uchars[i*4+j*width*4+2];
A=array->uchars[i*4+j*width*4+3];
SPRINTF(text, "%4d,%4d: R:%d G:%d B:%d A:%d", i, j, R, G, B, A);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
......@@ -286,7 +286,7 @@ void jpeg_error(j_common_ptr cinfo, int msg_level)
cinfo->err->num_warnings++;
}
gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_channel *channel)
gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_array *array)
{
JSAMPROW row_pt[1];
GdkPixbuf *pixbuf;
......@@ -305,7 +305,7 @@ gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
cinfo.err = jpeg_std_error(&jerr);
cinfo.err->emit_message = jpeg_error;
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, (uchar*) channel->data, channel->size);
jpeg_mem_src(&cinfo, (uchar*) array->data, array->size);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
row_stride = cinfo.output_width * cinfo.output_components;
......@@ -337,7 +337,7 @@ gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, void*)
{
int i, j;
uchar *data = (uchar*) channel->data;
uchar *data = (uchar*) array->data;
uint32_t *pixels;
int Y, Cb = 128, Cr = 128;
......@@ -347,7 +347,7 @@ gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, void*)
pixels = (uint32_t*)image_buffer;
i = 0;
while (i != (int) channel->size)
while (i != (int) array->size)
{
Y = data[i++];
Cb = data[i++];
......@@ -375,7 +375,7 @@ gboolean update_yuv2_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
int x, y;
int i, j;
uchar *data = (uchar*) channel->data;
uchar *data = (uchar*) array->data;
char text[NAME_MAX];
uint32_t *tmp_pixels;
int Y, U = 128, V = 128;
......@@ -385,7 +385,7 @@ gboolean update_yuv2_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
tmp_pixels = (uint32_t*)image_buffer;
i = 0;
while (i != (int) channel->size)
while (i != (int) array->size)
{
U = data[i++];
Y = data[i++];
......@@ -410,16 +410,16 @@ gboolean update_yuv2_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
if (i<width && j<height && i>=0 && j>=0)
{
if (mouse_channel.fd!=-1)
if (mouse_array.dims!=nullptr)
{
mouse_channel.uints32[0]=i;
mouse_channel.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_channel.uints32[2]));
mouse_array.uints32[0]=i;
mouse_array.uints32[1]=j;
gdk_device_get_state(pointer_device, gtk_widget_get_window(GTK_WIDGET(image)), NULL, (GdkModifierType*)(&mouse_array.uints32[2]));
}
Y=channel->uchars[i*2+j*width*2+1];
U=channel->uchars[i*4+j*width*2];
V=channel->uchars[i*4+j*width*2+2];
Y=array->uchars[i*2+j*width*2+1];
U=array->uchars[i*4+j*width*2];
V=array->uchars[i*4+j*width*2+2];
SPRINTF(text, "%d,%d: Y:%d, U:%d, V:%d", i, j, Y, U, V);
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
......@@ -511,28 +511,25 @@ int frame_rate(gpointer data)
return G_SOURCE_CONTINUE;
}
GtkWidget *create_image_display(blc_channel *tmp_channel)
GtkWidget *create_image_display(blc_array *tmp_array)
{
GtkWidget *pointer_statusbar, *framerate_statusbar;
char label_text[NAME_MAX + 1];
uint32_t type_string, format_string;
channel=tmp_channel;
array=tmp_array;
toolbar = gtk_toolbar_new();
general_statusbar=gtk_statusbar_new();
framerate_statusbar=gtk_statusbar_new();
pointer_statusbar=gtk_statusbar_new();
blc_loop_try_add_posting_semaphore(channel->sem_ack_data);
blc_loop_try_add_waiting_semaphore(channel->sem_new_data);
blc_command_loop_init(0);
switch (channel->format)
switch (array->format)
{
case 'NDEF':
case 'Y800':
width=channel->dims[0].length;
height=channel->dims[1].length;
width=array->dims[0].length;
height=array->dims[1].length;
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);
......@@ -540,25 +537,25 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
false_colors_button=blgtk_add_toggle_tool_button(toolbar, "false\ncolors", "applications-graphics", G_CALLBACK(false_color_cb), NULL);
break;
case 'BA81':
EXIT_ON_ARRAY_ERROR(channel, "format, Not fully implemented");
width=channel->dims[1].length;
height=channel->dims[2].length;
EXIT_ON_ARRAY_ERROR(array, "format, Not fully implemented");
width=array->dims[1].length;
height=array->dims[2].length;
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);
gtk_widget_add_tick_callback(GTK_WIDGET(image), (GtkTickCallback) update_RGB3_image, &g_source_continue, NULL);
break;
case 'RGB3':
width=channel->dims[1].length;
height=channel->dims[2].length;
width=array->dims[1].length;
height=array->dims[2].length;
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);
gtk_widget_add_tick_callback(GTK_WIDGET(image), (GtkTickCallback) update_RGB3_image, pointer_statusbar, NULL);
break;
case 'RGBA':
width=channel->dims[1].length;
height=channel->dims[2].length;
width=array->dims[1].length;
height=array->dims[2].length;
image_buffer = MANY_ALLOCATIONS(width*height * 4, uchar);
image_surface=cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4);
image=gtk_image_new_from_surface(image_surface);
......@@ -572,8 +569,8 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
image = gtk_image_new_from_pixbuf(pixbuf);
gtk_widget_add_tick_callback(image, (GtkTickCallback) update_JPEG_image, channel, NULL);*/
case 'YUYV':
width=channel->dims[1].length;
height=channel->dims[2].length;
width=array->dims[1].length;
height=array->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);
......@@ -581,8 +578,8 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
break;
case 'yuv2':case 'UYVY':
pthread_create(&init_table_thread, NULL, create_RGBA_from_YUYV, image);
width=channel->dims[1].length;
height=channel->dims[2].length;
width=array->dims[1].length;
height=array->dims[2].length;
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);
......@@ -603,7 +600,7 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
color_map=gray_colors;
g_timeout_add(1000, frame_rate, (gpointer)framerate_statusbar);
SPRINTF(label_text, "%.4s, %.4s, %dx%d", UINT32_TO_STRING(type_string, channel->type), UINT32_TO_STRING(format_string, channel->format), width, height);
SPRINTF(label_text, "%.4s, %.4s, %dx%d", UINT32_TO_STRING(type_string, array->type), UINT32_TO_STRING(format_string, array->format), width, height);
gtk_statusbar_push(GTK_STATUSBAR(general_statusbar), 0, label_text);
gtk_widget_set_vexpand(scrolled_window, TRUE);
gtk_widget_set_halign(image, GTK_ALIGN_START);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment