Example #1
0
static void sanalyzer_render_freq(gint16 data[2][256])
{
	gint i,c;
	gint y;

	gint xscale[] = {0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 101, 137, 187, 255};
	
	if(!window)
		return;
	for(i = 0; i < NUM_BANDS; i++)
	{
		for(c = xscale[i], y = 0; c < xscale[i + 1]; c++)
		{
			if(data[0][c] > y)
				y = data[0][c];
		}
		y >>= 7;
		if(y != 0)
		{
			y = (gint)(log(y) * scale);
			if(y > HEIGHT - 1)
				y = HEIGHT - 1;
		}
 
		if(y > bar_heights[i])
			bar_heights[i] = y;
		else if(bar_heights[i] > 4)
			bar_heights[i] -= 4;
		else
			bar_heights[i] = 0;
		
	}
	draw_func(NULL);
	return;			
}
Example #2
0
File: wdhdcpy.c Project: LuaDist/cd
static void _wdHdcpyDoit(cdCanvas *canvas, cdCanvas *canvas_copy, void (*draw_func)(cdCanvas *canvas_copy))
{
  cdCanvas *old_active;
  double  left, right, bottom, top;   /* canvas visualization window       */
  int     canvas_hsize, canvas_vsize; /* canvas sizes in pixels            */
  int     hdcpy_hsize, hdcpy_vsize;   /* paper sizes in points             */
  double  canvas_vpr;                 /* canvas viewport distortion ratio  */
  double  hdcpy_vpr;                  /* paper viewport distortion ratio   */
  int     xc, yc;                     /* paper center in pixels            */
  int     xmin, xmax, ymin, ymax;     /* paper viewport                    */

  /* Activate canvas visualization surface. */
  if (cdCanvasActivate(canvas) != CD_OK) return;

  /* Get current canvas window parameters and sizes. */
  wdCanvasGetWindow(canvas, &left, &right, &bottom, &top);
  cdCanvasGetSize(canvas, &canvas_hsize, &canvas_vsize, 0L, 0L);

  /* Activate hardcopy visualization surface. */
  if (cdCanvasActivate(canvas_copy) != CD_OK) return;

  /* Set window parameters on hardcopy surface. */
  wdCanvasWindow(canvas_copy, left, right, bottom, top);

  /* Adjust paper viewport, centralized, matching canvas viewport. */
  canvas_vpr = (double)canvas_vsize / (double)canvas_hsize;
  cdCanvasGetSize(canvas_copy, &hdcpy_hsize, &hdcpy_vsize, 0L, 0L);
  hdcpy_vpr = (double)hdcpy_vsize / (double)hdcpy_hsize;
  xc = (int)((double)hdcpy_hsize/2.0);
  yc = (int)((double)hdcpy_vsize/2.0);

  if (canvas_vpr < hdcpy_vpr)
  {
    xmin = 0;
    xmax = hdcpy_hsize;
    ymin = yc - (int)((double)hdcpy_hsize*(double)canvas_vpr/2.0);
    ymax = yc + (int)((double)hdcpy_hsize*(double)canvas_vpr/2.0);
  }
  else
  {
    xmin = xc - (int)((double)hdcpy_vsize/(double)canvas_vpr/2.0);
    xmax = xc + (int)((double)hdcpy_vsize/(double)canvas_vpr/2.0);
    ymin = 0;
    ymax = hdcpy_vsize;
  }

  cdCanvasClipArea(canvas_copy, xmin, xmax, ymin, ymax);
  cdCanvasClip(canvas_copy, CD_CLIPAREA);
  wdCanvasViewport(canvas_copy, xmin, xmax, ymin, ymax);

  /* for backward compatibility */
  old_active = cdActiveCanvas();
  cdActivate(canvas_copy);

  /* Draw on hardcopy surface.  */
  draw_func(canvas_copy);

  if (old_active) cdActivate(old_active);
}
Example #3
0
/* x,y in pixels */
void screen_put_iconxy(struct screen * display,
                       int xpos, int ypos, enum themable_icons icon)
{
    const void *data;
    const int screen = display->screen_type;
    const int width = ICON_WIDTH(screen);
    const int height = ICON_HEIGHT(screen);
    const int is_rtl = lang_is_rtl();
    int stride;
    const struct bitmap *iconset;
    screen_bitmap_part_func *draw_func = NULL;
    
    if (icon == Icon_NOICON)
    {
        if (is_rtl)
            xpos = display->getwidth() - xpos - width;
        screen_clear_area(display, xpos, ypos, width, height);
        return;
    }
    else if (icon >= Icon_Last_Themeable)
    {
        iconset = &iconsets[Iconset_viewers][screen].bmp;
        icon -= Icon_Last_Themeable;
        if (!iconsets[Iconset_viewers][screen].loaded || 
           (global_status.viewer_icon_count * height > iconset->height) ||
           (icon * height + height > iconset->height))
        {
            screen_put_iconxy(display, xpos, ypos, Icon_Questionmark);
            return;
        }
    }
    else if (iconsets[Iconset_user][screen].loaded)
    {
        iconset = &iconsets[Iconset_user][screen].bmp;
    }
    else
    {
        iconset = &inbuilt_iconset[screen];
    }
    data = iconset->data;
    stride = STRIDE(display->screen_type, iconset->width, iconset->height);

    /* add some left padding to the icons if they are on the edge */
    if (xpos == 0)
        xpos++;

    if (is_rtl)
        xpos = display->getwidth() - xpos - width;

#if (LCD_DEPTH == 16) || defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH == 16)
    if (display->depth == 16)
        draw_func   = display->transparent_bitmap_part;
    else
#endif
        draw_func   = display->bitmap_part;

    draw_func(data, 0, height * icon, stride, xpos, ypos, width, height);
}
Example #4
0
void
window::on_draw()
{
    if (m_canvas)
    {
        slot_draw_function draw_func(this);
        this->plot_apply(draw_func);
    }
}
static cairo_image_surface_t *
create_composite_mask (cairo_image_surface_t	*dst,
		       void			*draw_closure,
		       draw_func_t		 draw_func,
		       const cairo_composite_rectangles_t *extents)
{
    cairo_image_surface_t *surface;
    cairo_int_status_t status;

    surface = (cairo_image_surface_t *)
	_cairo_surface_create_similar_solid (&dst->base,
					     CAIRO_CONTENT_ALPHA,
					     extents->bounded.width,
					     extents->bounded.height,
					     CAIRO_COLOR_TRANSPARENT);
    if (unlikely (surface->base.status))
	return surface;

    status = draw_func (surface, draw_closure,
			CAIRO_OPERATOR_ADD, &_cairo_pattern_white.base,
			extents->bounded.x, extents->bounded.y,
			&extents->bounded);
    if (unlikely (status))
	goto error;

    if (extents->clip->boxes) {
	status = combine_in_boxes (surface,
				   extents->clip->boxes,
				   extents->clip->num_boxes,
				   &extents->bounded);
	if (unlikely (status))
	    goto error;
    }

    if (extents->clip->path) {
	status = _cairo_clip_combine_with_surface (extents->clip,
						   &surface->base,
						   extents->bounded.x,
						   extents->bounded.y);
	if (unlikely (status))
	    goto error;
    }

    return surface;

error:
    cairo_surface_destroy (&surface->base);
    return (cairo_image_surface_t *)_cairo_surface_create_in_error (status);
}
static cairo_image_surface_t *
create_composite_mask (cairo_image_surface_t	*dst,
		       void			*draw_closure,
		       draw_func_t		 draw_func,
		       const cairo_composite_rectangles_t *extents)
{
    cairo_image_surface_t *surface;
    cairo_int_status_t status;

    TRACE ((stderr, "%s\n", __FUNCTION__));

    surface = (cairo_image_surface_t *)
	_cairo_image_surface_create_with_pixman_format (NULL, PIXMAN_a8,
							extents->bounded.width,
							extents->bounded.height,
							0);
    if (unlikely (surface->base.status))
	return surface;

    status = draw_func (surface, draw_closure,
			CAIRO_OPERATOR_ADD, &_cairo_pattern_white.base,
			extents->bounded.x, extents->bounded.y,
			&extents->bounded);
    if (unlikely (status))
	goto error;

    status = _cairo_clip_combine_with_surface (extents->clip,
					       &surface->base,
					       extents->bounded.x,
					       extents->bounded.y);
    if (unlikely (status))
	goto error;

    return surface;

error:
    cairo_surface_destroy (&surface->base);
    return (cairo_image_surface_t *)_cairo_surface_create_in_error (status);
}
Example #7
0
void FlareManager::Flare::draw()
{
	if (draw_func) draw_func(this);
}