⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xcmap.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    Copyright (c) 1987, 1988, 1989, 1990, 1991 AT&T and/*    Entropic Research Laboratory, Inc.  All Rights Reserved.	*//*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*//*	AND ENTROPIC RESEARCH LABORATORY, INC.			*//*	The copyright notice above does not evidence any	*//*	actual or intended publication of such source code.	*//* xcmap.c *//*This is the beginnings of a colormap editor.  This version assumes acolormap size of CM_SIZE (must be power of 2).  Left mouse pics in thedisplayed colormap at the top of the frame cause "handles" to appearbelow the map.  Left pics in the region of these handles select them;middle pics remove the closest handle.  Movement of the mouse with leftbutton depressed inside the color "triangle" causes color mix tochange.  Movement of the "slider" causes the intensity of the selectedhandle to change.  Selected level number and RGB intensity levels aredisplayed at bottom of screen.  RGB intensity levels are linearlyinterpolated between handles.  A colormap is saved by entering an"OUTPUT file" name when the desired effect has been achieved.  Anexisting colormap may be read and modified by entering its name forthe "INPUT file" item.  These colormaps are in a form acceptable to the"wave" and "waves" programs.*/#ifndef lintstatic char *sccs_id = "@(#)xcmap.c	1.2	1/7/93	AT&T, ERL";#endif#include <stdio.h>#include <math.h>#include <sys/file.h>#include <xview/xview.h>#include <xview/font.h>#include <xview/canvas.h>#include <xview/panel.h>#include <xview/text.h>#include <xview/cms.h>#include <esps/exview.h>#define CM_SIZE 128#define RADIUS 350#define CM_WIDTH 1024Panel_item	file_item, infile_item, quit_item, slider;char		outputname[100] = "colormap", inputname[100] = "";Xv_singlecolor	colors[CM_SIZE];Cms		cms;int		bstart = 0, bwidth = CM_WIDTH/CM_SIZE, bheight = 75,		cheight = 510, cwidth = 1100, tox = 200, toy = 197,		intensity = 1000;typedef struct cbreak {    int		    where;    u_char	    r, g, b;    struct cbreak   *next, *prev;} Cbreak;Cbreak	cb1 = {CM_SIZE -1, 0, 0, 0, NULL, NULL};Cbreak	cb0 = {0, 255, 255, 255, &cb1, NULL};Cbreak	*cbp = &cb0;u_char	curr=255, curb=255, curg=255;Canvas	canvas;Panel	panel;Xv_font	font;/*************************************************************************/Cbreak *new_cbreak(where,r,g,b)int where, r, g, b;{  Cbreak  *cb, *cb2;  cb = &cb0;  while(cb) {    if(cb->where == where) {      cb->r = r;      cb->b = b;      cb->g = g;      return(cb);    }    if((cb->where < where) && (cb->next) && (cb->next->where > where)) {      cb2 = (Cbreak*)malloc(sizeof(Cbreak));      cb2->where = where;      cb2->r = r;      cb2->b = b;      cb2->g = g;      cb2->next = cb->next;      cb->next->prev = cb2;      cb->next = cb2;      cb2->prev = cb;      return(cb2);    }    cb = cb->next;  }  return(NULL);}extern int fullscreendebug;  /*************************************************************************/main(argc, argv)    int		argc;    char	**argv;{    Frame	frame, frm;    static void	newText(), doit(), repaint(), intensity_proc(), quit_proc();    fullscreendebug = 1; /* this global inhibits server grabs that cause			    problems on the SGI */    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);    font = (Xv_Font) xv_find(XV_NULL, FONT,			FONT_FAMILY,	    FONT_FAMILY_DEFAULT_FIXEDWIDTH,			0);    cb1.prev = &cb0;    frm = xv_create(XV_NULL, FRAME,			WIN_X,			    10,			WIN_Y,			    10,			XV_LABEL,		    "Colormap Generator",			0);    panel = xv_create(frm, PANEL, 0);    infile_item = xv_create(panel, PANEL_TEXT,			XV_Y,			    xv_row(panel, 0),			XV_X,			    xv_col(panel, 0),			PANEL_LABEL_STRING,	    "INPUT file:",			PANEL_VALUE_DISPLAY_LENGTH, 40,			PANEL_VALUE,		    inputname,			PANEL_NOTIFY_PROC,	    newText,			0);    file_item = xv_create(panel, PANEL_TEXT,			XV_Y,			    xv_row(panel, 1),			XV_X, 			    xv_col(panel, 0),			PANEL_LABEL_STRING,	    "OUTPUT file:",			PANEL_VALUE_DISPLAY_LENGTH, 40,			PANEL_VALUE,		    outputname,			PANEL_NOTIFY_PROC,	    newText,			0);    quit_item = xv_create(panel, PANEL_BUTTON,			XV_Y,			    xv_row(panel, 2),			XV_X, 			    xv_col(panel, 0),			PANEL_LABEL_STRING,	    "QUIT!",			PANEL_NOTIFY_PROC,	    quit_proc,			0);    slider = xv_create(panel, PANEL_SLIDER,			XV_Y,			    xv_row(panel, 2),			XV_X,			    xv_col(panel, 15),			PANEL_NOTIFY_LEVEL,	    PANEL_DONE,			PANEL_NOTIFY_PROC,	    intensity_proc,			PANEL_LABEL_STRING,	    "Brightness %",			PANEL_MIN_VALUE,	    0,			PANEL_MAX_VALUE,	    1000,			PANEL_SHOW_RANGE,	    TRUE,			PANEL_SHOW_VALUE,	    TRUE,			PANEL_SLIDER_WIDTH,	    300,			PANEL_VALUE,		    1000,			0);    window_fit(panel);    window_fit(frm);    (void) exv_attach_icon(frm, ERL_NOBORD_ICON, "cmap", TRANSPARENT);    frame = xv_create(XV_NULL, FRAME,			WIN_X,			    10,			WIN_Y,			    100,			XV_LABEL,		    "Colormap Generator",			0);    canvas = xv_create(frame, CANVAS,			CANVAS_AUTO_SHRINK,	    FALSE, 			CANVAS_AUTO_EXPAND,	    FALSE, 			XV_WIDTH,		    cwidth,			XV_HEIGHT,		    cheight,			CANVAS_WIDTH,		    cwidth,			CANVAS_HEIGHT,		    cheight,			CANVAS_PAINTWINDOW_ATTRS,			    WIN_DYNAMIC_VISUAL,		TRUE,			    0,			CANVAS_NO_CLIPPING,	    TRUE,			0);    xv_set(canvas_paint_window(canvas),			WIN_CONSUME_EVENTS,			    LOC_DRAG,			    WIN_IN_TRANSIT_EVENTS,			    LOC_MOVE,			    0,			WIN_EVENT_PROC,		    doit,			0);    window_fit(frame);    (void) exv_attach_icon(frame, ERL_NOBORD_ICON, "cmap", TRANSPARENT);    xv_set(canvas,	CANVAS_REPAINT_PROC,	    repaint,			0);    xv_set(frame,	WIN_SHOW,		    TRUE,			0);    cms = (Cms) xv_create(XV_NULL, CMS,			CMS_TYPE,		    XV_DYNAMIC_CMS,			CMS_SIZE,		    CM_SIZE,			0);    xv_main_loop(frm);    exit(0);}/*************************************************************************/static voidrepaint(canvas, pw, repaint_area)    Canvas	canvas;    Xv_window	pw;    Rectlist	*repaint_area;{    redraw_colormap();    draw_colorboxes();    plot_bp();    draw_color_triangle();}/*************************************************************************/draw_color_triangle(){  double    r = RADIUS,	    pi = 3.141592653589793238,	    dt = .01;  double    x, y, th, lim;  int	    xp, yp, xo, yo;  Pixwin    *pw;  pw = canvas_pixwin(canvas);  x = .5 + tox;  y = .5 + toy;  pw_text(pw, (int) x - 30, (int) y, PIX_SRC, font, "RED");  lim = pi/3.0;  for(th = dt, xo = x + r, yo = y; th < lim + dt; th += dt) {    if (th > lim) th = lim;    xp = x + r * cos(th);    yp = y + r * sin(th);    pw_vector(pw, xo, yo, xp, yp, PIX_SRC, 255);    xo = xp;    yo = yp;  }  x = .5 + tox + r;  y = .5 + toy;  pw_text(pw, (int) x, (int) y, PIX_SRC, font, "GREEN");  lim = pi/3.0;  for(th = dt, xo = tox, yo = toy; th < lim + dt; th += dt) {    if (th > lim) th = lim;    xp = x - r * cos(th);    yp = y + r * sin(th);    pw_vector(pw, xo, yo, xp, yp, PIX_SRC, 255);    xo = xp;    yo = yp;  }  x = .5 + tox + r*0.5;  y = .5 + toy + r*sqrt(3.0)/2.0;  pw_text(pw, (int) x + 20, (int) y, PIX_SRC, font, "BLUE");  lim = 2.0*pi/3.0;  for(th = pi/3.0 + dt, xo = x + r*0.5, yo = toy; th < lim + dt; th += dt) {    if (th > lim) th = lim;    xp = x + r * cos(th);    yp = y - r * sin(th);    pw_vector(pw, xo, yo, xp, yp, PIX_SRC, 255);    xo = xp;    yo = yp;  }}/*************************************************************************/static void newText(item, event)     Panel_item item;     Event *event;{  FILE *fdt, *fopen();  char *name, next[50], *get_output_file_names();  int n;  static int pin, pout;    if(item == file_item) {    strcpy(outputname, (char *) xv_get(item, PANEL_VALUE));    save_colormap(outputname);    return;  }  if(item == infile_item) {    strcpy(inputname, (char *) xv_get(item, PANEL_VALUE));    read_colormap(inputname);    return;  }}/*************************************************************************/save_colormap(name)    char    *name;{    FILE    *fd, *fopen();    int	    i;      if ((fd = fopen(name, "w")))    {	for (i = 0; i < CM_SIZE; i++)	    fprintf(fd, "%3d %3d %3d\n",		    colors[i].red, colors[i].green, colors[i].blue);	fclose(fd);    }}/*************************************************************************/read_colormap(name)    char    *name;{    FILE    *fd, *fopen();    int	    i, r, g, b;    char    line[120];      if ((fd = fopen(name, "r"))) {	for (i = 0; i < CM_SIZE; i++) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -