Exemple #1
0
//int ed_tilecol = 0;
gint VID_EditorUpdate(gpointer data)
{
	/*if(ed_tilecol >= 255-16)
		ed_tilecol = 0;

	int i, j;
	for(i = 0; i < vid.height; i++)
	{
		for(j = 0; j < vid.width; j++)
			ed_backtile->data[i * vid.width + j] = ed_tilecol;
		i += 16;
	}
	for(i = 0; i < vid.width; i++)
	{
		for(j = 0; j < vid.height; j++)
			ed_backtile->data[j * vid.width + i] = ed_tilecol;
		i += 16;
	}
	ed_tilecol++;
*/
	gdk_draw_indexed_image(gtk_widget_get_window(x_win), x_gc, 0, 0, ed_backtile->width, ed_backtile->height, GDK_RGB_DITHER_NONE, ed_backtile->data, ed_backtile->width, x_cmap); 

	if(ed_file)
	{
		gdk_draw_indexed_image(gtk_widget_get_window(ed_window), ed_pic, 0, ed_menubar->allocation.height, ed_file->width, ed_file->height, GDK_RGB_DITHER_NONE, ed_file->data, ed_file->width, ed_cmap); 
		gdk_draw_indexed_image(gtk_widget_get_window(ed_window), ed_pic, ed_file->width, ed_menubar->allocation.height, ed_palfile->width, ed_palfile->height, GDK_RGB_DITHER_NONE, ed_palfile->data, ed_palfile->width, ed_cmap);
		return 1;
	}
	
	gdk_draw_indexed_image(gtk_widget_get_window(ed_window), ed_pic, 0, ed_menubar->allocation.height, ed_palfile->width, ed_palfile->height, GDK_RGB_DITHER_NONE, ed_palfile->data, ed_palfile->width, ed_cmap); 

	return 1;
}
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;
}
Exemple #4
0
static void the_fftscope(void)
{
	guchar *loc;
	guchar bits [256 * 129];
	int i, h;

	running = 1;

	while (running) {
		guint val;
		gint j;
		gint k;

		memset(bits, 0, 256 * 128);

		for (i=0; i < BARS; i++) { 
			val = 0;
			for (j = xranges[i]; j < xranges[i + 1]; j++) {
				/* k = (guint)(sqrt(fftout[j]) * fftmult); */
				k = (fft_buf[j] + fft_buf[256+j]) / 256;
				val += k;
			}
			if(val > 127) val = 127;
			if (val > (guint)maxbar[ i ]) 
				maxbar[ i ] = val;
			else {
				k = maxbar[ i ] - (4 + (8 / (128 - maxbar[ i ])));
				val = k > 0 ? k : 0;
				maxbar[ i ] = val;
			}
			loc = bits + 256 * 128;
			for (h = val; h > 0; h--) {
				for (j = (256 / BARS) * i + 0; j < (256 / BARS) * i + ((256 / BARS) - 1); j++) {
					*(loc + j) = val-h;
				}
				loc -=256;
			}
		}
		GDK_THREADS_ENTER();
		gdk_draw_indexed_image(area->window, area->style->white_gc,
				0,0,256,128, GDK_RGB_DITHER_NONE, bits, 256, color_map);
		gdk_flush();
		GDK_THREADS_LEAVE();
		dosleep(SCOPE_SLEEP);
	}	
	GDK_THREADS_ENTER();
	fftscope_hide();
	GDK_THREADS_LEAVE();
}
Exemple #5
0
/* The actual FFTscope renderer function. */
static void the_fftscope()
{
	guint8 *loc;
	guint8 bits[256 * 129];
	int i, h;

	running = 1;

	while (running) {
		int w;
		guint val;

		memset(bits, 128, 256 * SCOPE_HEIGHT);

		for (i = 0; i < 256; i++) {
			val = (act_fft[i] + act_fft[i + 256]) / (64 * (128 / SCOPE_HEIGHT));
			if (val > (SCOPE_HEIGHT-1)) {
				val = (SCOPE_HEIGHT-1);
			}
			loc = bits + i + 256 * (SCOPE_HEIGHT-1);
			for (h = val; h > 0; h--) {
				*loc = h;
				loc -= 256;
			}
		}
		GDK_THREADS_ENTER();
		gdk_draw_indexed_image(area->window, area->style->white_gc,
				       0, 0, 256, SCOPE_HEIGHT, GDK_RGB_DITHER_NONE,
				       bits, 256, color_map);
		gdk_flush();
		GDK_THREADS_LEAVE();
		dosleep(SCOPE_SLEEP);
	}
	GDK_THREADS_ENTER();
	fftscope_hide();
	GDK_THREADS_LEAVE();
}
Exemple #6
0
/* draw a part of a pixmap info to the window */
void draw_pinfo(GdkWindow *w, GdkGC *gc,struct pixmap_info *p_info,
		int srcx,int srcy, int destx, int desty,
		int width, int height)
{
  guchar *bitbuf=p_info->row_pointers[srcy]+srcx*p_info->bit_depth/8;
  if (p_info->num_palette) {
    GdkRgbCmap* cmap=gdk_rgb_cmap_new(p_info->gdk_palette,
				      p_info->num_palette);
    
    /* printf("drawing %x:(%d,%d) to (%d,%d) w:%d h=%d\n",(int)p_info,
       srcx,srcy,destx,desty,width,height); */
    gdk_draw_indexed_image(w,gc,destx,desty,width,height,
			   GDK_RGB_DITHER_NONE,
			   bitbuf,p_info->row_len,
			   cmap);
    gdk_rgb_cmap_free(cmap);
  } else {
    gdk_draw_rgb_image(w,gc,destx,desty,width,height,
		       GDK_RGB_DITHER_NONE,bitbuf,
		       p_info->row_len);
	     
  }
  
}
Exemple #7
0
/* This is a generic rendering function.  It works for all signal styles.
 * The input always looks like one big PCM sample; if the input is really
 * a spectrum, then it will have been transformed by blurk_render_pcm()
 * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative
 * values representing a lot of sound.  This particular transformation was
 * chosen simply because the normal PCM plotter can then produce a nice-looking
 * spectrum graph.
 *
 * This function supports a variety of ways to plot the [pseudo-]PCM samples.
 * In addition to the usual line graph, it can also mirror the line graph or
 * produce a "bead" graph by passing the data off to render_bead().
 * The decision of how to plot is based on the value of "variation".
 */
static void update_image(gint32 loudness, gint ndata, gint16 *data)
{
	gint	i, y, thick, quiet, center;
	gint	beat;
	guchar	*img;
	gint	width, height, bpl;

#if 0
	/* If events are pending, then skip this frame */
	if (gdk_events_pending())
		return;
#endif

	/* If we completed a resize operation a few seconds ago, then save the
	 * new size now.
	 */
	if (savewhen != 0L && time(NULL) >= savewhen)
	{
		//config_write(FALSE, NULL, NULL);
		savewhen = 0L;
	}

	/* If we're supposed to be in fullscreen mode, and aren't, then
	 * toggle fullscreen mode now.
	 */
#if 0	 
	if (config.fullscreen_desired && !fullscreen_method)
		blursk_fullscreen(FALSE);
#endif

	/* Detect whether this is a beat, and choose a line thickness */
	beat = detect_beat(loudness, &thick, &quiet);

	/* If quiet, then maybe choose a new preset */
	//if (quiet)
		//preset_quiet();

	/* Perform the blurring.  This also affects whether the center of the
	 * signal will be moved lower in the window.
	 */
	center = img_height/2 + blur(beat, quiet);

	/* Perform the fade or solid flash */
	if (beat && !strcmp(config.flash_style, "Full flash"))
		i = 60;
	else
	{
		switch (config.fade_speed[0])
		{
		  case 'S':	i = -1;	break;	/* Slow */
		  case 'M':	i = -3;	break;	/* Medium */
		  case 'F':	i = -9;	break;	/* Fast */
		  default:	i = 0;		/* None */
		}
	}
	if (i != 0)
		loopfade(i);

	/* special processing for "Invert" & bitmap logo flashes */
	if (beat)
	{
		if (!strcmp(config.flash_style, "Invert flash"))
			img_invert();
		else if ((i = bitmap_index(config.flash_style)) >= 0)
			bitmap_flash(i);
	}

	/* Maybe change hue on beats */
	if (beat)
		color_beat();

	/* Add the signal data to the image */
	render(thick, center, ndata, data);

	/* Add floaters */
	drawfloaters(beat);

	/* shift the "ripple effect" from one frame to another */
	img_rippleshift += 3; /* cyclic, since img_rippleshift is a guchar */

	/* Apply the overall effect, if any */
	if (!strcmp(config.overall_effect, "Bump effect"))
	{
		img = img_bump(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Anti-fade effect"))
	{
		img = img_travel(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Ripple effect"))
	{
		img = img_ripple(&width, &height, &bpl);
	}
	else /* "Normal effect" */
	{
		img = img_expand(&width, &height, &bpl);
	}

	/* show info about the track */
	img = show_info(img, height, bpl);

	/* Allow the background color to change */
	color_bg(ndata, data);

	/* Copy the image into the window.  This also converts from
	 * 8-bits to 16/24/32 if necessary.
	 */
#if 0	 
	GDK_THREADS_ENTER();
#if HAVE_XV
	if (!xv_putimg(img, width, height, bpl))
#endif
		gdk_draw_indexed_image(area->window,
			area->style->white_gc,
			0, 0, width, height, GDK_RGB_DITHER_NONE,
			img, bpl, color_map);
	GDK_THREADS_LEAVE();
#endif
	/* Convert colors */
	uint32* pDst = (uint32*)blursk_bitmap->LockRaster();
	uint8* pSrc = img;
	

	for( y = 0; y < height; y++ )
	{
		for( i = 0; i < width; i++ )
		{
			*pDst++ = color_map[*pSrc++];
		}
		pSrc += bpl - width;
	}
	
	blursk_view->DrawBitmap( blursk_bitmap, blursk_bitmap->GetBounds(), blursk_bitmap->GetBounds() );
	blursk_view->Flush();
}