亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? xwindow.c

?? snake算法
?? C
?? 第 1 頁 / 共 2 頁
字號:
/****************************************************************************
 File Name  : xwindow.c
 Purpose    : provides x-window interface routines
 Release    : Version 1.0
 Date	    : Aug 31,1995

GSNAKE API is jointly developed by the Information Technology Institute (ITI), Singapore, and the School of Applied Science, Nanyang Technological
University (NTU), Singapore. 

These software programs are available to the user without any license or royalty fees. Permission is hereby granted to use, copy, modify, and distribute this software and its documentation for any purpose. ITI and NTU gives no warranty, express, implied, or statuary for the software and/or documentation provided, including, without limitation, waranty of merchantibility and warranty of fitness for a particular purpose. The software provided hereunder is on an "as is"  basis, and ITI and NTU has no obligation to provide maintenance, support, updates, enhancements, or modifications.

GSNAKE API is available for any UNIX compatible system. User feedback, bugs, or software and manual suggestions should be sent via electronic mail to one of the following, who may or may not act on them as he/she desires :

		asschan@ntu.ac.sg
		kflai@iti.gov.sg
***************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gsnake.h"

/* ---- internal constants and variables used by x window manager ---- */
#define COLORMAPSIZE	256
#define ALLOC_COLOR	1		/* allocate color for snaxel */
#define TITLE		"gsnake"
#define VERBOSE		1
#define INCH            72      	/* one inch = 72 points */
#define BORDERWIDTH	5		/* border width = 5 pixels */


static int		FirstTime = 1 ;		/* to raise X window */

static Display         *gDisplay=NULL;		/* display and others */
static int		gScreen;
static Window		gWindow;
static Visual		*gVisual;
static GC       	imageGC;		/* graphic contexts */
static GC		pointGC ;
static GC		rectGC;
static unsigned long 	pixels[COLORMAPSIZE];	/* pixel values */
static int		c_map_size;		/* colormap size */
static XEvent		any_event;
static char 		*Title = NULL;

/* expand ratio for higher level snaxels */
static int              ci_expand = 1;
static int              POINT_DIM = 3;  /* dimension of point in plotting */
static int              POINT_OFF = 0; /* offset in plotting point */


/* ----- internal function prototypes ------ */
int 	xwin_init(short width, short height, char *title, char alloc_color, 
		char verbose);
void 	xwin_close(void);
Display *xwin_setupXWindow(char *DisplayName, char *title, short width, 
		short height, int *screen, Window *window, Visual **visual, 
		int verbose);
void 	xwin_setupGC(unsigned long *pixels, int *c_map_size, char alloc_color);



void xwin_setTitle(char *title)
{
	Title = strdup(title);
}

void xwin_raiseWindow(short width, short height)
{
	if( FirstTime ) {
		xwin_init(width, height, ((Title) ? Title : TITLE), 1, VERBOSE);
		FirstTime = 0 ;		
	}
	
	else
	 	XResizeWindow(gDisplay, gWindow, width, height);
}

/* create an x window of specified dimensions and initialize the graphics
   context to display gray level images and drawing snake points and lines */
xwin_init(
	short 	width, 
	short 	height,		/* size of x window to be raised */
	char 	*title,		/* title of the window */
	char 	alloc_color,	/* 1 : alloc color for points */
	char 	verbose		/* 1 : turns verbose on */
) {	
	/* create and raise X window */
	gDisplay = xwin_setupXWindow((char *) NULL, title, width, height, 
				&gScreen, &gWindow, &gVisual, verbose) ;

	/* create gray level GC */
	xwin_setupGC(pixels, &c_map_size, alloc_color);	

	return (gDisplay) ? 1 : 0 ;
} 

/* close the x window */
void xwin_close(void)
{
	if(gDisplay) XCloseDisplay(gDisplay) ;
}

/* create a raise a simple X window */
Display *xwin_setupXWindow(
	char 	*DisplayName,		/* name of display */
	char	*title,			/* title of window */
	short	width, 
	short	height,			/* width and height of window */
	int	*screen,		/* RETURN : default screen */
	Window  *window,		/* RETURN : created window */
	Visual  **visual,		/* RETURN : POINTER to vidual found */
	int	verbose			/* 1 : set verbose on */
){
	Display *display ;	/* graphic display */
	Window rootWindow ;	/* the root window */
	XSizeHints gHint ;	/* hints to X Server on window raising */
	unsigned long gForegrnd, gBackgrnd ;
	int status, depth ;
	

	/* connect to default X Server */
	display = XOpenDisplay(DisplayName) ;
	if( display == NULL ) { 
      		fprintf(stderr, "\nERROR: Cannot connect to X server [%s]\n", 
			  XDisplayName(DisplayName) );
      		return NULL ;
   	}
 
   	*screen = DefaultScreen( display);
  	rootWindow = RootWindow( display, *screen);
   	gBackgrnd = WhitePixel( display, *screen);
   	gForegrnd = BlackPixel( display, *screen);
   	
   	*visual = DefaultVisual(display, *screen) ;
   	depth = DefaultDepth(display, *screen) ;

	/* provide hints on where to raise the window */
	gHint.x = 100 ;
	gHint.y = 200 ;
   	gHint.width = width ;	
   	gHint.height =  height ; 
	gHint.flags = PPosition | PSize;

	/* actually create the window */
	*window = XCreateSimpleWindow( display, rootWindow, 
			gHint.x, gHint.y, gHint.width, gHint.height,
			(unsigned int) BORDERWIDTH, gForegrnd, gBackgrnd);


	XSetWMNormalHints(display, *window, &gHint) ;

   	XSelectInput( display, *window, 
			ButtonPressMask | KeyPressMask | ExposureMask |
			ButtonReleaseMask | Button1MotionMask );
	
  	XMapRaised(display, *window);
	XStoreName(display, *window, title);
	XFlush(display) ;

	/* print out information on x window if required */
	if( verbose == 1 ) {
		
			
		fprintf(stdout, "\n%s version %d of the %s\n",
				ServerVendor(display),
				VendorRelease(display),
				"X Window System") ;
		
		fprintf(stdout, "Color plane depth : %d %s\n\n", depth,
				( (depth == 1) ? "(mono)": "") ) ;
	}
	return display ;
}



/* set-up graphics context */
void xwin_setupGC(
	unsigned long *pixels,
	int *c_map_size,
	char alloc_color
) {
   	XGCValues gc_values;
   	unsigned long mask;
   	XColor xcolor, rgb_color, hw_color;
   	int i, j, status ;
	Colormap color_map;
	
	*c_map_size = 0 ;
	color_map = DefaultColormap(gDisplay, gScreen) ;
		
      	while (XAllocColorCells(gDisplay, color_map, False, NULL, 0,
	     &(pixels[*c_map_size]), 1))
		(*c_map_size)++;

      	xcolor.flags = DoRed | DoGreen | DoBlue;
      	for (i = 0; i < *c_map_size; ++i)
      	{
		xcolor.pixel = pixels[i];
	 	xcolor.red = (unsigned short) (i << 8);
	 	xcolor.green = (unsigned short) (i << 8); 
	 	xcolor.blue = (unsigned short) (i << 8); 
	 	XStoreColor(gDisplay, color_map, &xcolor);
      	}

	/* this is the GC for handling the image */
      	mask = GCForeground | GCBackground | GCLineWidth | GCFunction;
      	gc_values.function = GXcopy;
      	gc_values.foreground = pixels[*c_map_size - 1];
      	gc_values.background = pixels[0];
      	gc_values.line_width = 2 ;
      	imageGC = XCreateGC(gDisplay, gWindow, mask, &gc_values);

	/* this is the GC for handling the points */
	if( alloc_color ) {
		hw_color.pixel = gc_values.foreground ;
		status = XAllocNamedColor(gDisplay, color_map, "red", 
				&hw_color, &rgb_color) ;
		gc_values.foreground = hw_color.pixel ;
	}
		
	pointGC = XCreateGC(gDisplay, gWindow, mask, &gc_values) ;
	XSetForeground(gDisplay, pointGC, (unsigned long) gc_values.foreground);
   
	/* this is the GC for handling the line */
	if( alloc_color ) {
		hw_color.pixel = gc_values.foreground ;
		status = XAllocNamedColor(gDisplay, color_map, "green", 
				&hw_color, &rgb_color) ;
		gc_values.foreground = hw_color.pixel ;
	}
		
	rectGC = XCreateGC(gDisplay, gWindow, mask, &gc_values) ;
	XSetForeground(gDisplay, rectGC, (unsigned long) gc_values.foreground);
}

XImage *xwin_creatXimage(float *data, short height, short width, unsigned char magnify)		
{
	register short i, j, m, n ;
	unsigned char *box ;
	float *dptr ;
	float maxmag, minmag;
	double range ;
	int index ;
	
  	/*  Set up an image data structure for handling the image. */
	box = (unsigned char *) _iMemAlloc(sizeof(unsigned char) * 
			height * width * magnify * magnify) ;
					
	for(i=0, dptr=data, maxmag = minmag = *dptr ; i<height; i++)
	   for(j=0; j<width; j++, dptr++) {
	   	maxmag = MAX(maxmag, *dptr);
	   	minmag = MIN(minmag, *dptr);
	   }
	range = (maxmag - minmag)/0.9 ;	/* use 90% of the range */
	
	/* put values in ximage data pointer */
	for (i = 0, dptr=data; i < height; ++i)
            for (j = 0; j < width; ++j, ++dptr)  {
            	
		index = (int) ((double) c_map_size * (*dptr-minmag)/range);
		
	    	for(m=0; m<magnify; m++)
	    	  for(n=0; n<magnify; n++) 
	    	  	box[(i*magnify+m)*magnify*width + 
	    	  	     j*magnify + n] = pixels[index] ;
	}

	return XCreateImage(gDisplay, DefaultVisual(gDisplay, gScreen), 
			    (unsigned int) 8, ZPixmap, 0, (char *) box, 
			    width*magnify, magnify*height, 8,  
			    width*magnify);   
}

void xwin_drawImg(XImage *ximg, int xoffset, int yoffset)
{
	XPutImage(gDisplay, gWindow, imageGC, ximg, 
		0, 0, xoffset, yoffset, ximg->width, ximg->height) ;
	XFlush(gDisplay) ; 
}

void xwin_DrawLine( short x1, short y1, 
		    short x2, short y2, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产色爱av资源综合区| 国产乱码精品一区二区三区五月婷 | 中文子幕无线码一区tr| 国产美女在线观看一区| 久久久不卡网国产精品二区| 国产成人精品免费一区二区| 中文字幕一区免费在线观看| 91国模大尺度私拍在线视频| 亚洲丶国产丶欧美一区二区三区| 678五月天丁香亚洲综合网| 日本aⅴ免费视频一区二区三区| 精品国产乱码久久久久久影片| 国产精品一区二区久激情瑜伽| 国产精品福利在线播放| 色噜噜狠狠色综合欧洲selulu| 亚洲国产裸拍裸体视频在线观看乱了| 欧美高清你懂得| 国产在线精品一区二区夜色| 亚洲欧洲三级电影| 欧美日本乱大交xxxxx| 国产一区二区三区精品欧美日韩一区二区三区 | 九九国产精品视频| 日本一区二区三区视频视频| 色欧美乱欧美15图片| 日韩精品视频网站| 欧美极品少妇xxxxⅹ高跟鞋 | 黄一区二区三区| 国产精品久久久久精k8| 欧美熟乱第一页| 国产成人免费网站| 亚洲国产成人精品视频| 国产精品欧美久久久久一区二区| 欧美午夜精品免费| 粉嫩av一区二区三区在线播放 | 99免费精品在线观看| 日韩激情视频网站| 国产精品伦理一区二区| 日韩一区二区三区四区| 91麻豆视频网站| 激情图区综合网| 亚洲动漫第一页| 国产精品视频一二三区| 欧美一区二区精品久久911| av在线不卡电影| 国产精品自拍毛片| 日韩精品一区第一页| 亚洲狠狠丁香婷婷综合久久久| wwwwww.欧美系列| 欧美福利视频导航| 91国偷自产一区二区使用方法| 国产高清精品久久久久| 奇米一区二区三区av| 亚洲一区二区影院| 国产精品久久久久久久久快鸭| 精品女同一区二区| 67194成人在线观看| 欧美少妇xxx| 在线视频一区二区三区| 丁香婷婷综合五月| 国产老女人精品毛片久久| 日本美女一区二区三区| 亚洲国产毛片aaaaa无费看| 一区二区三区四区视频精品免费| 国产农村妇女精品| 国产亚洲欧美日韩俺去了| 日韩欧美国产一区二区在线播放| 欧美日韩国产在线播放网站| 91在线porny国产在线看| 成人美女视频在线观看18| 粉嫩高潮美女一区二区三区| 成人免费观看av| 成人97人人超碰人人99| 大美女一区二区三区| 成人午夜又粗又硬又大| 国产馆精品极品| 岛国精品在线播放| gogo大胆日本视频一区| 91一区在线观看| 色综合天天综合给合国产| 99视频国产精品| 91久久精品日日躁夜夜躁欧美| 色婷婷av一区二区三区之一色屋| 91久久国产最好的精华液| 欧美日韩在线三级| 51精品国自产在线| 欧美v亚洲v综合ⅴ国产v| 日韩欧美黄色影院| 国产拍欧美日韩视频二区| 欧美国产激情一区二区三区蜜月| 一区在线观看视频| 亚洲一区二区影院| 另类专区欧美蜜桃臀第一页| 经典一区二区三区| 从欧美一区二区三区| 91视频观看视频| 欧美三级电影网| 欧美电影免费提供在线观看| 精品美女一区二区三区| 国产精品欧美久久久久无广告 | 亚洲国产成人在线| 日韩一区欧美小说| 亚洲午夜精品17c| 亚洲成人av免费| 狠狠色狠狠色合久久伊人| 国产一区二区三区观看| 99久久精品国产精品久久| 色综合久久中文综合久久97| 制服.丝袜.亚洲.另类.中文 | av午夜精品一区二区三区| 色就色 综合激情| 欧美一区二区在线看| 26uuu另类欧美亚洲曰本| 中文字幕在线不卡视频| 日韩精品三区四区| 懂色av一区二区三区免费看| aaa亚洲精品一二三区| 欧美美女激情18p| 国产丝袜欧美中文另类| 亚洲一区精品在线| 国产成a人亚洲| 欧美日韩激情在线| 国产精品欧美一区二区三区| 日韩一区精品字幕| 不卡电影一区二区三区| 欧美久久久影院| 欧美色手机在线观看| 91精品国产乱码| 亚洲欧美日韩电影| 极品尤物av久久免费看| 欧美在线小视频| 久久久国产午夜精品| 一区二区高清免费观看影视大全| 另类欧美日韩国产在线| 91久久久免费一区二区| 久久网站热最新地址| 亚洲国产精品尤物yw在线观看| 国产成人av电影在线| 日韩一级精品视频在线观看| 亚洲欧洲av一区二区三区久久| 久久av中文字幕片| 欧美精品高清视频| 亚洲视频一区二区在线| 国产成人超碰人人澡人人澡| 日韩一二在线观看| 午夜免费欧美电影| 91久久免费观看| 日产国产欧美视频一区精品| 成人一道本在线| 欧美精品一区二区三区蜜臀| 日韩高清不卡在线| 在线亚洲一区二区| 国产精品久久久久精k8| 成人免费毛片aaaaa**| 久久这里都是精品| 免费人成黄页网站在线一区二区| 欧美片网站yy| 亚洲乱码国产乱码精品精的特点| 国产成人免费在线观看不卡| 久久这里只有精品首页| 久88久久88久久久| 日韩女优av电影| 老司机精品视频导航| 日韩一区二区三区免费看| 亚洲愉拍自拍另类高清精品| 在线看日韩精品电影| 亚洲免费伊人电影| 色88888久久久久久影院按摩| 国产精品伦一区| 91在线无精精品入口| 一区二区中文字幕在线| 99久久精品免费看国产免费软件| 中文字幕精品一区二区精品绿巨人| 国产精品一品二品| 国产免费观看久久| 99久久99久久久精品齐齐| 亚洲精品欧美二区三区中文字幕| 91激情在线视频| 午夜激情久久久| 日韩午夜小视频| 国产又黄又大久久| 国产精品久久99| 欧美三区在线观看| 日韩激情av在线| 久久亚洲春色中文字幕久久久| 国产一区二区网址| 中文字幕一区二区三区色视频 | 久久综合资源网| 成人精品免费看| 一区二区三区在线视频观看58 | 亚洲午夜av在线| 日韩一区二区三区视频| 国产麻豆精品久久一二三| 国产精品进线69影院| 91官网在线观看| 免费在线观看视频一区| 国产精品福利一区| 欧美久久久久久久久中文字幕| 国产一区欧美二区| 亚洲美女精品一区| 日韩一二在线观看|