forked from Miroirs/x49gp
draw pixel using cairo_rectangle
This commit is contained in:
parent
b179f88451
commit
c9191b6c00
1 changed files with 16 additions and 21 deletions
|
@ -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 )
|
void x49gp_draw_rectangle( GdkPixmap* target, int x, int y, int w, int h, GdkColor* color )
|
||||||
{
|
{
|
||||||
cairo_t* cr = gdk_cairo_create (target);
|
cairo_t* cr = gdk_cairo_create( target );
|
||||||
cairo_set_source_rgb( cr, color->red, color->green, color->blue );
|
|
||||||
|
|
||||||
cairo_rectangle (cr, x, y, w, h );
|
cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 );
|
||||||
cairo_fill (cr);
|
cairo_rectangle( cr, x, y, w, h );
|
||||||
|
cairo_fill( cr );
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy( cr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void x49gp_lcd_update( x49gp_t* x49gp )
|
void x49gp_lcd_update( x49gp_t* x49gp )
|
||||||
{
|
{
|
||||||
x49gp_ui_t* ui = x49gp->ui;
|
x49gp_ui_t* ui = x49gp->ui;
|
||||||
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
|
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,
|
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 );
|
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_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 );
|
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 );
|
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_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 );
|
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_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 );
|
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++ )
|
||||||
for ( int y = 0; y < ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE; y++ ) {
|
x49gp_draw_rectangle( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height,
|
||||||
for ( int x = 0; x < ui->lcd_width / LCD_PIXEL_SCALE; x++ ) {
|
LCD_PIXEL_SCALE, LCD_PIXEL_SCALE,
|
||||||
color = x49gp_get_pixel_color( lcd, x, y );
|
&(ui->colors[ UI_COLOR_GRAYSCALE_0 + 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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
|
|
Loading…
Reference in a new issue