/* --- winn.c ver1.4 */
/*This is a sample program for processing image data*/
/* originally coded by Go Nagahama in 1997 */
/* revised by Hideki Hashizume (modification for ANSI) in 1998 */
/* revised by Masaki Oshima extended to treat ras(monochrome, color), gray.
served in a set of modular progs.
/* 1st release(ver1.0) 1999.10.01 */
/* ver1.1 released 1999.10.13 */
/* ver1.4 released 2001.06.14 */
/* last modification 2001.06.15 */
/* usage example winn ~/Video_data/gazou/hirosue.ras */
#include <stdio.h>
#include "vismain.h"
int main(int argc, char
*argv[])/*==============================================
=*/
{
char data_name[100];
unsigned char *vdata, *vdisp;
int width, height, depth, gray, bwrev;
XColor *color; int pixs;
struct rasin *rasin;
static Window win1;
int points;
XImage *image; XStandardColormap *scmap;
Colormap cmap; /* 2000.08.10*/
XEvent event;
if( argc < 2 ){
printf("Usage: [Program][data_name]\n");
return (int)NULL;
}
sprintf(data_name,"%s",argv[1]); /*データ名の設定*/
/*画像ファイルデータの読み込み rasinはデータ入力のための領域 visio.h参照*/
rasin = get_image(data_name, &width, &height, &pixs);
if(rasin == NULL) goto err;
vdata = rasin->vdata; /* vdataは入力画像の入っている領域 */
color = rasin->color; /* colorはXColor形式のカラーデータ */
points = width * height; /* 画素点の数を横幅と縦幅から計算 */
if(rasin->dir_col == True){ /* ifが成立するときダイレクトカラー画像 */
/* if(rasin->color_data == True){ */
/* scmapはダイレクトカラー画像のとき用いる標準カラーマップ形式のデータ */
scmap = rasin->scmap;
/* vdata(ダイレクトカラー)からscmapに従って表示用の8ビット形式vdispを作
る
*/
vdisp = data_to_disp(vdata, points, scmap, pixs, rasin);
}else{
vdisp = vdata; /* カラーマップのあるデータ(非ダイレクトカラー)
のときはvdispはvdataと同じでよい */
}
cmap = set_cmap(color, pixs, rasin); /* カラーマップの設定 */
/* bwrev = set_cmap(win1, color, pixs);*/ /* カラーマップの設定 */
win1 = win_set(width, height, "output data", cmap); /* ウインドウの設定
*/
/* win1 = win_set(width, height, "output data");*/
depth =8;
gray = rasin->gray;
/* 表示用データimageをcolorに従って作成 */
image = mk_image (vdisp, width, height, depth, win1, color, pixs, gray);
XSelectInput(disp, win1, ExposureMask | ButtonPressMask );
fprintf(stderr, "goto event loop\n");
while(1){
XNextEvent( disp, &event );
switch( event.type ){
case Expose :
fprintf(stderr, "Expose event\n");
XPutImage(disp,win1,gc,image,0,0,0,0,
width,height);
XFlush(disp);
break;
case ButtonPress :
fprintf(stderr, "ButtonPress event\n");
goto lpout;
}
}
lpout:
XFree(image); /* 使用したメモリを解放する */
free(vdata); free(vdisp);
return SUCCESS;
/* エラー時の処理 */
err: printf("error in main\n");
return FAIL;
}
/* End of main */
戻る