Example #1
0
static gint expose_CB (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
	if ((frame) && (mainWindow))
	{
		guchar *pixels;
		unsigned int rowstride;
		unsigned int imageWidth, imageHeight, areaWidth, areaHeight;

		_semaphore.Wait();
		yarpImage2pixbuf(&_inputImg, frame);
		_semaphore.Post();
 
		imageWidth = _inputImg.GetWidth();
		imageHeight = _inputImg.GetHeight();
		areaWidth = event->area.width;
		areaHeight = event->area.height;

		if ( (areaWidth != imageWidth) || (areaHeight != imageHeight) )
		{
			GdkPixbuf *scaledFrame;
			scaledFrame = gdk_pixbuf_scale_simple(	frame,
													areaWidth,
													areaHeight,
													GDK_INTERP_BILINEAR); // Best quality
													//GDK_INTERP_NEAREST); // Best speed

			pixels = gdk_pixbuf_get_pixels (scaledFrame);
			rowstride = gdk_pixbuf_get_rowstride(scaledFrame);
			gdk_draw_rgb_image (widget->window,
				widget->style->black_gc,
				event->area.x, event->area.y,
				event->area.width, event->area.height,
				GDK_RGB_DITHER_NORMAL,
				pixels,
				rowstride);
			g_object_unref(scaledFrame);
			
		}
		else
		{
			pixels = gdk_pixbuf_get_pixels (frame);
			rowstride = gdk_pixbuf_get_rowstride(frame);
			gdk_draw_rgb_image (widget->window,
					widget->style->black_gc,
					event->area.x, event->area.y,
					event->area.width, event->area.height,
					GDK_RGB_DITHER_NORMAL,
					pixels,
					rowstride);
		}
	}
	return TRUE;
}
Example #2
0
static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
{
#ifdef HAVE_OPENGL
    CvWindow* window = (CvWindow*)data;

    if (window->useGl)
    {
        drawGl(window);
        return TRUE;
    }
#else
    (void)data;
#endif

  CvImageWidget *image_widget;

  g_return_val_if_fail (widget != NULL, FALSE);
  g_return_val_if_fail (CV_IS_IMAGE_WIDGET (widget), FALSE);
  g_return_val_if_fail (event != NULL, FALSE);

  if (event->count > 0)
    return FALSE;

  image_widget = CV_IMAGE_WIDGET (widget);

  gdk_window_clear_area (widget->window,
                         0, 0,
                         widget->allocation.width,
                         widget->allocation.height);
  if( image_widget->scaled_image ){
      // center image in available region
      int x0 = (widget->allocation.width - image_widget->scaled_image->cols)/2;
      int y0 = (widget->allocation.height - image_widget->scaled_image->rows)/2;

      gdk_draw_rgb_image( widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
          x0, y0, MIN(image_widget->scaled_image->cols, widget->allocation.width),
          MIN(image_widget->scaled_image->rows, widget->allocation.height),
          GDK_RGB_DITHER_MAX, image_widget->scaled_image->data.ptr, image_widget->scaled_image->step );
  }
  else if( image_widget->original_image ){
      gdk_draw_rgb_image( widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
          0, 0,
          MIN(image_widget->original_image->cols, widget->allocation.width),
           MIN(image_widget->original_image->rows, widget->allocation.height),
          GDK_RGB_DITHER_MAX, image_widget->original_image->data.ptr, image_widget->original_image->step );
  }
  return TRUE;
}
Example #3
0
static void display_redraw(display_t *d, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
{
  unsigned int rowstride;
  unsigned int ofs;

  if ( display_darea == NULL )
    return;
  if ( d->rgb == NULL )
    return;

  debug(DEBUG_REFRESH, "REDRAW %ux%u+%d+%d\n", w, h, x, y);

  /* Clip refresh area to actual RGB buffer */ 
  if ( (x + w) > d->rgb_width )
    w = d->rgb_width - x;
  if ( (y + h) > d->rgb_height )
    h = d->rgb_height - y;

  /* Compute buffer offset */
  rowstride = DISPLAY_BPP * d->rgb_width;
  ofs = (rowstride * y) + (DISPLAY_BPP * x);

  gdk_draw_rgb_image(GTK_WIDGET(display_darea)->window, GTK_WIDGET(display_darea)->style->fg_gc[GTK_STATE_NORMAL],
                     x, y, w, h,
                     GDK_RGB_DITHER_NONE, d->rgb + ofs, rowstride);
}
Example #4
0
/* Drawing callback */
int gtkFloatExposeEvent (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
	SDL_PixelFormat screenPixFormat;
	SDL_Surface *rawImage, *screenImage;
	
	rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 192*2, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
	if(rawImage == NULL) return 1;
	
	memcpy(&screenPixFormat, rawImage->format, sizeof(SDL_PixelFormat));
	
	screenPixFormat.BitsPerPixel = 24;
	screenPixFormat.BytesPerPixel = 3;
	screenPixFormat.Rshift = 0;
	screenPixFormat.Gshift = 8;
	screenPixFormat.Bshift = 16;
	screenPixFormat.Rmask = 0x0000FF;
	screenPixFormat.Gmask = 0x00FF00;
	screenPixFormat.Bmask = 0xFF0000;
	
	screenImage = SDL_ConvertSurface(rawImage, &screenPixFormat, 0);
  
	gdk_draw_rgb_image	(widget->window,
							  widget->style->fg_gc[widget->state],0,0,screenImage->w, screenImage->h,
							  GDK_RGB_DITHER_NONE,(guchar*)screenImage->pixels,screenImage->pitch);
	SDL_FreeSurface(screenImage);
	SDL_FreeSurface(rawImage);
	
	return 1;
}
Example #5
0
gint area_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
	view_struct *vs;
	vs = (view_struct *) data;
  	if (event->count > 0) {
    		return(TRUE);
  	}
	if (GTK_IS_DRAWING_AREA(vs->area)) {
		if (vs->if_rgb) {
			gdk_draw_rgb_image(vs->area->window,
				vs->area->style->fg_gc[GTK_WIDGET_STATE (vs->area)],
				0,0,vs->width, 
				vs->height,
				GDK_RGB_DITHER_NONE,
				vs->buf8,
				3*vs->width);
		}
		else {
			gdk_draw_gray_image(vs->area->window, 
				vs->area->style->black_gc,
				0, 0, vs->width, 
				vs->height, 
				GDK_RGB_DITHER_NONE, 
				vs->buf8,
				vs->width);
		}
	}
	return TRUE;
}
Example #6
0
static void* draw_framebuffer_data(GtkWidget *widget)
{
    char *pixels;
    struct fb_fix_screeninfo fix;
    struct fb_var_screeninfo var;

    get_screen_info(&var, &fix);
    gtk_widget_set_size_request(widget, var.xres, var.yres);
    pixels = mmap(NULL, fix.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb0, 0);

    switch (var.bits_per_pixel) {
    case 24:
        gdk_draw_rgb_image(widget->window,
                widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
                var.xoffset, var.yoffset, var.xres, var.yres,
                GDK_RGB_DITHER_NONE, pixels, fix.line_length);
    case 32:
        gdk_draw_rgb_32_image(widget->window,
                widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
                var.xoffset, var.yoffset, var.xres, var.yres,
                GDK_RGB_DITHER_NONE, pixels, fix.line_length);
        break;
    }

    munmap(pixels, fix.smem_len);
}
Example #7
0
static void
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
{
	GdkPixbuf *pixbuf;

	pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");

	if (gdk_pixbuf_get_has_alpha (pixbuf)) {
		gdk_draw_rgb_32_image (drawing_area->window,
				       drawing_area->style->black_gc,
				       event->area.x, event->area.y, 
				       event->area.width, 
				       event->area.height,
				       GDK_RGB_DITHER_MAX, 
				       gdk_pixbuf_get_pixels (pixbuf)
				       + (event->area.y * gdk_pixbuf_get_rowstride (pixbuf)) 
				       + (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
				       gdk_pixbuf_get_rowstride (pixbuf));
	} else {
		gdk_draw_rgb_image (drawing_area->window,
				    drawing_area->style->white_gc,
				    event->area.x, event->area.y, 
				    event->area.width, 
				    event->area.height,
				    GDK_RGB_DITHER_NORMAL,
				    gdk_pixbuf_get_pixels (pixbuf)
				    + (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
				    + (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
				    gdk_pixbuf_get_rowstride (pixbuf));
	}
}
Example #8
0
static gint expose_preview( GtkWidget *widget, GdkEventExpose *event )
{
	int rx, ry, rw, rh;

	rx = event->area.x;
	ry = event->area.y;
	rw = event->area.width;
	rh = event->area.height;

	if ( ry < PREVIEW_HEIGHT )
	{
		if ( (ry+rh) >= PREVIEW_HEIGHT )
		{
			rh = PREVIEW_HEIGHT - ry;
		}
		gdk_draw_rgb_image( widget->window, widget->style->black_gc,
				rx, ry, rw, rh,
				GDK_RGB_DITHER_NONE,
				mem_prev + 3*( rx + PREVIEW_WIDTH*ry ),
				PREVIEW_WIDTH*3
				);
	}

	return FALSE;
}
void backend_gtk_redraw( gpointer _data )
{
   struct backend_data *data = _data;

   if( ( data->format.size.width == data->output_width ) &&
       ( data->format.size.height == data->output_height ) )
   {
      if( data->image_data[ data->current_buffer ] )
      {
	 gdk_draw_rgb_image( data->overlay_window, 
			     data->overlay_gc, 
			     data->crop_x, data->crop_y, 
			     data->crop_w, data->crop_h, 
			     GDK_RGB_DITHER_NONE, 
			     data->image_data[ data->current_buffer ], 
			     data->format.size.width * 3 );      
      }
   }
   else
   {
      if( data->pixbuf )
      {
	 gdk_draw_pixbuf( data->overlay_window, 
			  data->overlay_gc, 
			  data->pixbuf, 
			  0, 0, 
			  0, 0, 
			  -1, -1, 
			  GDK_RGB_DITHER_NONE, 
			  0, 0 );
      }
   }  
}
gint Repaint(gpointer data) {
   GtkWidget * widget = (GtkWidget *)data;
#ifdef TRUE_COLOR
   gdk_draw_rgb_image(  widget->window,
                        widget->style->fg_gc[GTK_STATE_NORMAL],
                        0,
                        0,
                        SCREEN_XRES,
                        SCREEN_YRES,
                        GDK_RGB_DITHER_NONE,
                        (guchar *)(V_CPU.shm_base_addr + SCRN_OFFSET + SHM_SCRN_IOCTL),
                        SCREEN_XRES*(SCREEN_BPP/8));
#else
   gdk_draw_indexed_image(  widget->window,
                            widget->style->fg_gc[GTK_STATE_NORMAL],
                            0,
                            0,
                            SCREEN_XRES,
                            SCREEN_YRES,
                            GDK_RGB_DITHER_NORMAL,
                            (guchar *)(V_CPU.shm_base_addr + SCRN_OFFSET + SHM_SCRN_IOCTL),
                            SCREEN_XRES,
                            V_CPU.cmap);
#endif
   return TRUE;
}
gint on_darea_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
#ifdef TRUE_COLOR
   gdk_draw_rgb_image(  widget->window,
                        widget->style->fg_gc[GTK_STATE_NORMAL],
                        0,
                        0,
                        SCREEN_XRES,
                        SCREEN_YRES,
                        GDK_RGB_DITHER_NONE,
                        (guchar *)(V_CPU.shm_base_addr + SCRN_OFFSET + SHM_SCRN_IOCTL),
                        SCREEN_XRES*(SCREEN_BPP/8));
#else
   gdk_draw_indexed_image(  widget->window,
                            widget->style->fg_gc[GTK_STATE_NORMAL],
                            0,
                            0,
                            SCREEN_XRES,
                            SCREEN_YRES,
                            GDK_RGB_DITHER_NORMAL,
                            (guchar *)(V_CPU.shm_base_addr + SCRN_OFFSET + SHM_SCRN_IOCTL),
                            SCREEN_XRES,
                            V_CPU.cmap);
#endif
   return FALSE;
}
Example #12
0
static gint button_press_event( GtkWidget      *widget,
                                GdkEventButton *event )
{
  static GdkGC *copy_gc = NULL;
  int x, y;
  
  x = event->x;
  y = event->y;

  pos_x[pos_nr] = (double) x;
  pos_y[pos_nr] = (double) y;

  pos_nr = (pos_nr+1) % 2;

  draw_test();

  if (copy_gc == NULL) {
    copy_gc = gdk_gc_new(widget->window);
  }

  gdk_draw_rgb_image(widget->window,
		     copy_gc,
		     0, 0,
		     width, height,
		     GDK_RGB_DITHER_NONE,
		     rgbdata, width*3 );

  return TRUE;
}
/* rethink: benefits from handling data 8 bit? (no shift round) */
inline void 
inline_draw_hue_bar                             (GtkWidget *widget, 
                                                 int x, 
                                                 int y, 
                                                 int w, 
                                                 int h, 
                                                 int sy, 
                                                 int sh)
{
    HildonColorChooserPrivate *priv = HILDON_COLOR_CHOOSER_GET_PRIVATE (widget);

    unsigned short hvec, hcurr;
    unsigned char *buf, *ptr, tmp[3];
    int i, j, tmpy;
    g_assert (priv);

    if (w <= 0 || h <= 0) {
        return;
    }

    buf = (unsigned char *) g_malloc (w * h * 3);

    hvec = 65535 / sh;
    hcurr = hvec * (y - sy);
    
    ptr = buf;

    for (i = 0; i < h; i++) {
        intern_h2rgb8 (hcurr, tmp);

        for (j = 0; j < w; j++) {
            ptr[0] = tmp[0];
            ptr[1] = tmp[1];
            ptr[2] = tmp[2];
            ptr += 3;
        }

        hcurr += hvec;
    }


    gdk_draw_rgb_image (widget->parent->window, 
            widget->style->fg_gc[0], 
            x, y, 
            w, h, 
            GDK_RGB_DITHER_NONE, buf, w * 3);

    tmpy = priv->hba.y + (priv->currhue * priv->hba.height / 0xffff);
    gdk_draw_line (widget->parent->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], priv->hba.x, tmpy, priv->hba.x + priv->hba.width - 1, tmpy);

    if ((((priv->currhue * priv->hba.height) & 0xffff) > 0x8000) && (tmpy < (priv->hba.y + priv->hba.height))) {
        gdk_draw_line (widget->parent->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 
                priv->hba.x, tmpy+1, priv->hba.x + priv->hba.width - 1, tmpy+1);
    } else if (tmpy > priv->hba.y) {
        gdk_draw_line(widget->parent->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], priv->hba.x, 
                tmpy-1, priv->hba.x + priv->hba.width - 1, tmpy-1);
    }

    g_free(buf);
}
Example #14
0
static void process_image(unsigned char *p, int len)
{
	if (grab) {
		FILE *f;

		f = fopen("image.dat", "w");
		fwrite(p, 1, len, f);
		fclose(f);
		printf("image dumped to 'image.dat'\n");
		exit(EXIT_SUCCESS);
	}
#ifdef WITH_V4L2_LIB
	if (v4lconvert_convert(v4lconvert_data,
				&src_fmt,
				&fmt,
				p, len,
				dst_buf, fmt.fmt.pix.sizeimage) < 0) {
		if (errno != EAGAIN)
			errno_exit("v4l_convert");
		return;
	}
	p = dst_buf;
	len = fmt.fmt.pix.sizeimage;
#endif
#ifdef WITH_GTK
	gdk_draw_rgb_image(drawing_area->window,
			   drawing_area->style->white_gc,
			   0, 0,		/* xpos, ypos */
			   fmt.fmt.pix.width, fmt.fmt.pix.height,
//			   GDK_RGB_DITHER_MAX,
			   GDK_RGB_DITHER_NORMAL,
			   p,
			   fmt.fmt.pix.width * 3);
#else
	fputc('.', stdout);
#endif
	if (info && io != V4L2_MEMORY_MMAP) {
		if (--info <= 0) {
			__time_t sec;
			long int usec;
			int d1, d2;

			sec = cur_time.tv_sec;
			usec = cur_time.tv_usec;
			gettimeofday(&cur_time, 0);
			d1 = cur_time.tv_sec - sec;
			d2 = cur_time.tv_usec - usec;
			while (d2 < 0) {
				d2 += 1000000;
				d1--;
			}
			printf("FPS: %5.2fd\n",
				(float) NFRAMES / (d1 + 0.000001 * d2));
			info = NFRAMES;
		}
	}
}
Example #15
0
File: leak.c Project: s7ephen/leak
gboolean update_portplot_map(GtkWidget *leak) {
	int startport, i, j, k;
	int x, y, q;

	if (zoom_onoff == FALSE) {
		gdk_draw_rgb_image (leak->window,
			leak->style->fg_gc[GTK_STATE_NORMAL],
			0, 
			0, 
			PORT_WIDTH, 
			PORT_HEIGHT,
     			GDK_RGB_DITHER_MAX, 
			portplot_rgbbuf, 
			PORT_WIDTH * 3);
	} 

	if (zoom_onoff == TRUE) {
		startport = GTK_ADJUSTMENT (scroll_params)->value * 4096;

		for (i = startport; i < startport+4096; i = i++) {

			x = i % 64;
			y = i / 64;
	
			for (j = 0; j <= 3; j++) {
				for (k = 0; k <= 3; k++) {
					zoombuf[3*(x*4+j)+768*(4*y+k)] = portplot_rgbbuf[3*i];
					zoombuf[3*(x*4+j)+768*(4*y+k)+1] = portplot_rgbbuf[3*i+1];
					zoombuf[3*(x*4+j)+768*(4*y+k)+2] = portplot_rgbbuf[3*i+2];
				}
			}
		}

		gdk_draw_rgb_image (leak->window,
			leak->style->fg_gc[GTK_STATE_NORMAL],
			0, 
			0, 
			PORT_WIDTH, 
			PORT_HEIGHT,
     			GDK_RGB_DITHER_MAX, 
			zoombuf, 
			PORT_WIDTH * 3);
	}
}
Example #16
0
void
draw_preview_image (gboolean recompute)
{
  gint      startx, starty, pw, ph;
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0xFFFF;
  color.green = 0xFFFF;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_COPY);

  compute_preview_rectangle (&startx, &starty, &pw, &ph);

  if (recompute)
    {
      GdkDisplay *display = gtk_widget_get_display (previewarea);
      GdkCursor  *cursor;

      cursor = gdk_cursor_new_for_display (display, GDK_WATCH);

      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      compute_preview (startx, starty, pw, ph);
      cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);
      gdk_flush ();

      /* if we recompute, clear backbuf, so we don't
       * restore the wrong bitmap */
      if (backbuf.image != NULL)
        {
          g_object_unref (backbuf.image);
          backbuf.image = NULL;
        }
    }

  gdk_draw_rgb_image (previewarea->window, gc,
                      0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT,
                      GDK_RGB_DITHER_MAX, preview_rgb_data,
                      3 * PREVIEW_WIDTH);

  /* draw symbols if enabled in UI */
  if (mapvals.interactive_preview)
    {
      draw_handles ();
    }
}
Example #17
0
File: svv.c Project: engie/robo_gui
void gui_gtk_update(unsigned char *p, int len)
{
	gdk_draw_rgb_image(
               gtk_widget_get_window(g_ui.drawing_area),
			   gtk_widget_get_style(g_ui.drawing_area)->white_gc,
			   0, 0,		/* xpos, ypos */
			   fmt.fmt.pix.width, fmt.fmt.pix.height,
			   GDK_RGB_DITHER_NORMAL,
			   p,
			   fmt.fmt.pix.width * 3);
}
Example #18
0
void show(void)
{
  gdk_draw_rgb_image (drawing_area->window,
			 drawing_area->style->white_gc,
			 0, 0, WWIDTH, WHEIGHT,
		      /* GDK_RGB_DITHER_NORMAL, */
		      GDK_RGB_DITHER_NONE,
		      /* GDK_RGB_DITHER_MAX, */
			 (guchar*)disp, WWIDTH*3);
  gdk_flush();
}
Example #19
0
File: leak.c Project: s7ephen/leak
gboolean update_countplot_map(GtkWidget *leak) {
	gdk_draw_rgb_image (leak->window,
		leak->style->fg_gc[GTK_STATE_NORMAL],
		0, 
		0, 
		PORT_WIDTH, 
		PORT_HEIGHT,
     		GDK_RGB_DITHER_MAX, 
		countplot_rgbbuf, 
		PORT_WIDTH * 3);
}
Example #20
0
void
nr_gdk_draw_rgba32_solid (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h, guint32 rgba)
{
	NRPixBlock pb;

	nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, 0, 0, w, h, FALSE);

	nr_render_rgba32_rgb (NR_PIXBLOCK_PX (&pb), w, h, pb.rs, x, y, rgba);
	gdk_draw_rgb_image (drawable, gc, x, y, w, h, GDK_RGB_DITHER_MAX, NR_PIXBLOCK_PX (&pb), pb.rs);

	nr_pixblock_release (&pb);
}
Example #21
0
static gboolean update_camera(GtkWidget *webcam)
{
	char *data = camera_read_image();
	if(data==NULL)
		return TRUE;
	int x, y;
	unsigned char *send_data = NULL;
	int bytes = network_encode_data(data, &send_data);
	g_free(send_data);
	gdk_draw_rgb_image(webcam->window,gdk_gc_new(webcam->window),0,0,WIDTH, HEIGHT ,GDK_RGB_DITHER_NONE,data,WIDTH*3);
	return TRUE;
}
Example #22
0
void
draw_preview_image (gint docompute)
{
  gint startx, starty, pw, ph;
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0xFFFF;
  color.green = 0xFFFF;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_COPY);
  linetab[0].x1 = -1;

  pw = PREVIEW_WIDTH * mapvals.zoom;
  ph = PREVIEW_HEIGHT * mapvals.zoom;
  startx = (PREVIEW_WIDTH - pw) / 2;
  starty = (PREVIEW_HEIGHT - ph) / 2;

  if (docompute == TRUE)
    {
      GdkDisplay *display = gtk_widget_get_display (previewarea);
      GdkCursor  *cursor;

      cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      compute_preview (0, 0, width - 1, height - 1, pw, ph);

      cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
      gdk_window_set_cursor(previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      clear_light_marker ();
    }

  if (pw != PREVIEW_WIDTH || ph != PREVIEW_HEIGHT)
    gdk_window_clear (previewarea->window);

  gdk_draw_rgb_image (previewarea->window, gc,
                      startx, starty, pw, ph,
                      GDK_RGB_DITHER_MAX,
                      preview_rgb_data, 3 * pw);

  draw_lights (startx, starty, pw, ph);
}
Example #23
0
static gboolean
ui_update(Bubblemon *base)
{
  int w, h, i;
  const bubblemon_picture_t *bubblePic;
  bubblemon_color_t *pixel;
  guchar *p;

  GdkGC *gc;

  GtkWidget *draw_area = base->draw_area;

  if((draw_area == NULL) ||
     !GTK_WIDGET_REALIZED(draw_area) ||
     !GTK_WIDGET_DRAWABLE(draw_area) ||
     base->width <= 0)
    {
      return TRUE;
    }

  bubblePic = bubblemon_getPicture(base->bubblemon);
  if ((bubblePic == NULL) ||
      (bubblePic->width == 0) ||
      (bubblePic->pixels == 0))
    {
      return TRUE;
    }
  w = bubblePic->width;
  h = bubblePic->height;

  gc = gdk_gc_new(draw_area->window);

  p = base->rgb_buffer;
  pixel = bubblePic->pixels;
  for(i = 0; i < w * h; i++) {
    *(p++) = pixel->components.r;
    *(p++) = pixel->components.g;
    *(p++) = pixel->components.b;
    pixel++;
  }

  gdk_draw_rgb_image(draw_area->window, gc,
                     0, 0,
                     base->width, base->height,
                     GDK_RGB_DITHER_NORMAL,
                     base->rgb_buffer, w * 3);

  gdk_gc_destroy(gc);

  return TRUE;
}
Example #24
0
void paint_from_rgb_cache(GtkWidget *widget, struct map_cache *cache, GdkRectangle *area)
{
	unsigned char *dat;
	if (!area_in_cache(area, cache)) {
		err_printf("paint_from_cache: oops - area not in cache\n");
		d3_printf("area is %d by %d starting at %d,%d\n",
			  area->width, area->height, area->x, area->y);
		d3_printf("cache is %d by %d starting at %d,%d\n",
			  cache->w, cache->h, cache->x, cache->y);
//		return;
	}
	dat = cache->dat + (area->x - cache->x
		+ (area->y - cache->y) * cache->w) * 3;
	gdk_draw_rgb_image (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
			     area->x, area->y, area->width, area->height,
			     GDK_RGB_DITHER_MAX, dat, cache->w*3);
}
static gint expose_tablet_preview( GtkWidget *widget, GdkEventExpose *event )
{
	unsigned char *rgb;
	int i, x = event->area.x, y = event->area.y, w = event->area.width, h = event->area.height;

	rgb = malloc( w*h*3 );
	if ( rgb == NULL ) return FALSE;

	for ( i=0; i<(w*h*3); i++ ) rgb[i] = 255;		// Pure white

	gdk_draw_rgb_image (widget->window, widget->style->black_gc,
			x, y, w, h, GDK_RGB_DITHER_NONE, rgb, w*3 );

	free( rgb );

	return FALSE;
}
Example #26
0
void
gkrellm_update(GtkWidget *widget, GdkDrawable *drawable, int start_x, int proximity)
{

    bm.screen_type = 1;
    /* get system statistics */
    get_memory_load_percentage();

    /* update main rgb buffer: bm.rgb_buf */
    bubblemon_update(proximity);

    gdk_draw_rgb_image(drawable, widget->style->fg_gc[GTK_STATE_NORMAL], start_x, 0, 56, 56, GDK_RGB_DITHER_NONE, bm.rgb_buf, 56 * 3);


    if (memscreen_enabled)
	roll_history();
}
Example #27
0
void
nr_gdk_draw_gray_garbage (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h)
{
	gint xx, yy;

	for (yy = y; yy < y + h; yy += 64) {
		for (xx = x; xx < x + w; xx += 64) {
			NRPixBlock pb;
			gint ex, ey;
			ex = MIN (xx + 64, x + w);
			ey = MIN (yy + 64, y + h);
			nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8, xx, yy, ex, ey, FALSE);
			nr_pixblock_render_gray_noise (&pb, NULL);
			gdk_draw_rgb_image (drawable, gc, xx, yy, ex - xx, ey - yy, GDK_RGB_DITHER_NONE, NR_PIXBLOCK_PX (&pb), pb.rs);
			nr_pixblock_release (&pb);
		}
	}
}
Example #28
0
void on_darea_expose (GtkWidget *widget) {

    GdkRectangle rect_oi;
//	static time_t init, end;
//	static frames;
//	unsigned char title[20];

//	if (!frames) {
//		time (&init);
//	}

    if (!buf) {
        return;
    }
    //brilho(buf);

    //rect_oi.x
    //rect_oi.y
//	rect_oi.width=COLS;
//	rect_oi.height=ROWS;
//	bgr2rgb(buf, COLS*ROWS);

//	gdk_threads_enter();
    swap_rgb24(buf, grab_size);
    gdk_draw_rgb_image (widget->window,
                        //widget->style->white_gc, 0, 0,
                        widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 0, 0,
                        COLS, ROWS, GDK_RGB_DITHER_NORMAL,
                        buf, COLS * DEPTH);

//	gtk_widget_draw(widget, &rect_oi);
//	gdk_threads_leave();

//	frames++;
//	time (&end);
//	if (end - init >= 1) {
//		global_frames=frames;
//		frames=0;
    //  		sprintf(title, "FPS %d - %d", global_frames, end - init);
//		gtk_statusbar_push (GTK_STATUSBAR (status), 1, title);
//		fprintf(stderr,"%s\n", title);
//	}

}
Example #29
0
static void
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
{
	GdkPixbuf *pixbuf;

	pixbuf = (GdkPixbuf *)g_object_get_data (G_OBJECT (drawing_area), "pixbuf");

	if (gdk_pixbuf_get_has_alpha (pixbuf)) {
		GdkPixbuf *dest;
                cairo_t *cr;
	  
		gdk_window_set_back_pixmap (drawing_area->window, NULL, FALSE);
	  
		dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
		
		gdk_pixbuf_composite_color (pixbuf, dest,
					    0, 0, event->area.width, event->area.height,
					    -event->area.x, -event->area.y,
					    (double) drawing_area->allocation.width / gdk_pixbuf_get_width (pixbuf),
					    (double) drawing_area->allocation.height / gdk_pixbuf_get_height (pixbuf),
					    GDK_INTERP_BILINEAR, 255,
					    event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
		
                cr = gdk_cairo_create (drawing_area->window);

                gdk_cairo_set_source_pixbuf (cr, dest, 0, 0);
                gdk_cairo_rectangle (cr, &event->area);
                cairo_fill (cr);

                cairo_destroy (cr);
		g_object_unref (dest);
	} else {
		gdk_draw_rgb_image (drawing_area->window,
				    drawing_area->style->white_gc,
				    event->area.x, event->area.y, 
				    event->area.width, 
				    event->area.height,
				    GDK_RGB_DITHER_NORMAL,
				    gdk_pixbuf_get_pixels (pixbuf)
				    + (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
				    + (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
				    gdk_pixbuf_get_rowstride (pixbuf));
	}
}
Example #30
0
/* Redraw the screen from the backing pixmap */
static gint expose_event( GtkWidget      *widget,
                          GdkEventExpose *event )
{
  static GdkGC *copy_gc = NULL;

  if (copy_gc == NULL) {
    copy_gc = gdk_gc_new(widget->window);
  }

  gdk_draw_rgb_image(widget->window,
		     copy_gc,
		     event->area.x, event->area.y,
		     event->area.width, event->area.height,
		     GDK_RGB_DITHER_NONE,
		     rgbdata + event->area.x*3+event->area.y*3*width,
		     width*3 );

  return FALSE;
}