1
0
Fork 0
forked from Miroirs/x49gp

draw pixel using cairo_rectangle

This commit is contained in:
Gwenhael Le Moine 2024-10-29 18:13:12 +01:00
parent b179f88451
commit c9191b6c00
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -283,20 +283,20 @@ static int x49gp_get_pixel_color( s3c2410_lcd_t* lcd, int x, int y )
void x49gp_draw_rectangle( GdkPixmap* target, int x, int y, int w, int h, GdkColor* color )
{
cairo_t* cr = gdk_cairo_create (target);
cairo_set_source_rgb( cr, color->red, color->green, color->blue );
cairo_t* cr = gdk_cairo_create( target );
cairo_rectangle (cr, x, y, w, h );
cairo_fill (cr);
cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 );
cairo_rectangle( cr, x, y, w, h );
cairo_fill( cr );
cairo_destroy (cr);
cairo_destroy( cr );
}
void x49gp_lcd_update( x49gp_t* x49gp )
{
x49gp_ui_t* ui = x49gp->ui;
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
//cairo_t* cr;
// cairo_t* cr;
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( ui->window )->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0,
0, ui->lcd_width, ui->lcd_height );
@ -308,6 +308,11 @@ void x49gp_lcd_update( x49gp_t* x49gp )
gdk_gc_set_rgb_fg_color( ui->ann_left_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_left_gc, true, 11, 0, 15, 12 );
/* cr = gdk_cairo_create( ui->ann_left ); */
/* gdk_cairo_set_source_pixbuf( cr, ui->lcd_pixmap, 11, 0 ); */
/* cairo_paint( cr ); */
/* cairo_destroy( cr ); */
color = x49gp_get_pixel_color( lcd, 131, 2 );
gdk_gc_set_rgb_fg_color( ui->ann_right_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_right_gc, true, 56, 0, 15, 12 );
@ -328,21 +333,11 @@ void x49gp_lcd_update( x49gp_t* x49gp )
gdk_gc_set_rgb_fg_color( ui->ann_io_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_io_gc, true, 236, 0, 15, 12 );
GdkGC* gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
for ( int y = 0; y < ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE; y++ ) {
for ( int x = 0; x < ui->lcd_width / LCD_PIXEL_SCALE; x++ ) {
color = x49gp_get_pixel_color( lcd, x, y );
/* gdk_gc_set_rgb_fg_color( gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) ); */
/* gdk_draw_rectangle( ui->lcd_pixmap, gc, true, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height, */
/* LCD_PIXEL_SCALE, LCD_PIXEL_SCALE ); */
x49gp_draw_rectangle( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height, LCD_PIXEL_SCALE, LCD_PIXEL_SCALE, &(ui->colors[ UI_COLOR_GRAYSCALE_0 + color ]) );
}
}
g_object_unref( gc );
for ( int y = 0; y < ( ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE ); y++ )
for ( int x = 0; x < ( ui->lcd_width / LCD_PIXEL_SCALE ); x++ )
x49gp_draw_rectangle( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height,
LCD_PIXEL_SCALE, LCD_PIXEL_SCALE,
&(ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ]) );
}
GdkRectangle rect;