/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC90X 4ch画像圧縮同時表示 4CH_DISP.C */ /*[作成者]S.Kodama */ /* 目的: 関数: 履歴: Ver 1.0 97/11/07 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 */ /* * Include compiler runtime library */ #include #include /* * Include CSC90X library */ #include "f_stdlib.h" #include "f_time.h" #include "f_gui.h" #include "f_stdio.h" #include "f_graph.h" #include "f_image.h" #include "f_pinf.h" #include "f_video.h" #include "f_system.h" /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void Sub_4ch_input( void ); /* 画像の取り込み(4面取り込み、圧縮表示) */ void image_contraction_copy( int, int, int ); /* 圧縮・転送サブルーチン */ void Sub_single_channel( void ); /* 単チャンネル表示 */ extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 4 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " 4CH DISP ", "4画面圧縮" }, { " 1CH DISP ", " 個別表\示 " }, { " PROC3 ", " 処理3 " }, { " PROC4 ", " 処理4 " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 #define MAX_IMAGE_NO 5 /* 画像取り込み最大面数(ここでは カメラ0〜カメラ3 入力用4               面と圧縮表示用1面を用意する。計5面)。 */ /* * メイン */ void main( void ) { int sts; int xpos; int ypos; int s_xpos; int s_ypos; int i; /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; /* 入力ビデオ制御 */ Lib_input_video_control( GRAY_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /***** STORAGE上に5面のグレイメモリ(GRAYMEM0〜4.SYS)を生成 *****/ for( i = 0; i < MAX_IMAGE_NO; i++ ) /* 現在生きている面数を調べる */ if( ERROR_RETURN == Lib_change_gray_memory( i ) ) break; for( ; i < MAX_IMAGE_NO; i++ ) /* 5面まで確保する */ { if( ERROR_RETURN != Lib_alloc_gray_memory() ) Lib_gray_memory_cls(i); else { Lib_freeze( NOT_TRANSMIT ); Lib_memory_clear( GRAY_PLANE | CHAR_PLANE ); Lib_chrdisp( 20, 13, "最低限必要な5面のグレイメモリ" ); Lib_chrdisp( 20, 14, "が確保できませんでしたので処理" ); Lib_chrdisp( 20, 15, "を中止し、901システム標準機能に戻り" ); Lib_chrdisp( 20, 16, "ます。" ); for( Lib_strtclk(); Lib_readclk() < 1000; ) ; return; } } /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); Sub_4ch_input(); /* 画像の取り込み(4面取り込み、圧縮表示) */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); main_menu_disp(); } else if ( xpos > MENU_2_XS && xpos < MENU_2_XE && ypos > MENU_2_YS && ypos < MENU_2_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); Sub_single_channel(); /* 単チャンネル表示 */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], (char *)str_main_menu[1][iLanguage], (char *)NULL, (char *)NULL ); } /* * ヘルプ表示 */ static void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】 4CH_DISP" ); Lib_chrdisp( 11, 10, "全ビデオ入力チャネル(4ch)の画像を圧縮して" ); Lib_chrdisp( 11, 12, "モニタに同時表\示します。" ); } /**************************************************************/ /**** 4画面圧縮表示 ******************************************/ /**************************************************************/ void Sub_4ch_input() { static char disp_buff[50]; int i, time; /* 画面クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE | GRAY_PLANE ); /* 画像(4面分)取り込み。 カメラ0=GRAYMEM0.SYS , カメラ1=GRAYMEM1.SYS */ for( i = 0; i < 4; i++ ) /* カメラ2=GRAYMEM2.SYS , カメラ3=GRAYMEM3.SYS */ { Lib_xvideo_channel( WAITING, i ); Lib_change_gray_memory( i ); Lib_time_delay( 40 ); /* カメラ間で同期をとれば、このディレイ・タイムは必要ありません */ Lib_freeze( NOT_TRANSMIT ); } /* タイマースタート(処理時間計測用) */ Lib_strtclk_count(); /* 各入力済み画像(4面)の圧縮・転送(→GRAYMEM4.SYS) */ for( i = 0; i < 4; i++ ) image_contraction_copy( i, 4, i ); /* 圧縮画像表示 */ Lib_xvideo_transmit( 4, GRAY_PLANE ); /* 処理時間表示 */ time = ( Lib_readclk_count() * 8138 ) / 10000; Lib_sprintf( disp_buff, "%3dmsec", time ); Lib_chrdisp( 58, 1, disp_buff ); /* カメラ番号のキャラクタ重畳表示 */ Lib_chrdisp( 13, 15, "カメラ CH0" ); Lib_chrdisp( 45, 15, "カメラ CH1" ); Lib_chrdisp( 13, 30, "カメラ CH2" ); Lib_chrdisp( 45, 30, "カメラ CH3" ); } /*=======================================================================*/ /* 単機能サブルーチン */ /*=======================================================================*/ /* 指定メモリ番号の画像を1/2に圧縮して指定番号の画像メモリへコピーする。 */ /* その際、コピー先の位置も指定できる。 */ /*************************************************************************/ void image_contraction_copy( source_no, destination_no, position_no ) int source_no; /* 転送元のグレイメモリ番号( 0〜15 ) */ int destination_no; /* 1/2圧縮後の転送先グレイメモリ番号( 0〜15 ) */ int position_no; /* 1/2画像の転送位置( 0〜3 ) → | */ /* 0 | 1 */ /* -----+----- */ /* 2 | 3 */ /* | */ { register char *sorc_mem, *dest_mem; register int x, y; sorc_mem = Lib_adrs_gray_memory( source_no ); dest_mem = Lib_adrs_gray_memory( destination_no ); switch( position_no ) { case 0: break; case 1: dest_mem += 256; break; case 2: dest_mem += 512 * 240; break; case 3: dest_mem += 512 * 240 + 256; break; } for( y = 0; y < 240; y++ ) { for( x = 0; x < 256; x++ ) { *dest_mem++ = *sorc_mem; sorc_mem += 2; } sorc_mem += 512; dest_mem += 256; } } /**************************************************************/ /**** 単チャンネル表示(1カメラの1画面表示) ****************/ /**************************************************************/ void Sub_single_channel() { static char disp_buff[12]; int i, w, h, ew, eh, x, y, old; /* 画面クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* アクティブ・チャンネルを 0 にする */ Lib_xvideo_channel( WAITING, 0 ); /* 画像フリーラン */ Lib_freerun(); /* タイトル表示 */ Lib_chrdisp( 15, 1, "★★★ シングルチャンネルのフリーラン表\示 ★★★" ); /* キーサイズ取得 */ Lib_get_key_size( 9, &w, &h ); /* チャンネル・キーを表示 */ Lib_display_key( 0, 0, "●カメラ CH0", 1 ); for( i = 1; i < 4; i++ ) { Lib_sprintf( disp_buff, "○カメラ CH%1d", i ); Lib_display_key( 0, h * i, disp_buff, 1 ); } /* 終了キー表示 */ Lib_get_key_size( 4, &ew, &eh ); Lib_display_key( 511 - ew, 0, "終了", 1 ); /* 切り換え作業 */ for( old = 0; ; ) { if( CURSOR_EXECUTE == Lib_get_current_position( &x, &y ) ) { if( 0 <= x && x <= w && 0 <= y && y <= h * 4 ) { /* カーサー位置が何処のキー上にあるかチェック */ for( i = 0; i < 4; i++ ) if( i * h <= y && y <= (i+1) * h ) break; /* その位置のキー表示をプッシュ、及びチャンネル切り換え */ Lib_sprintf( disp_buff, "●カメラ CH%1d", i ); Lib_display_key( 0, h * i, disp_buff, 2 ); Lib_xvideo_channel( WAITING, i ); if( old != i ) { Lib_sprintf( disp_buff, "○カメラ CH%1d", old ); Lib_display_key( 0, h * old, disp_buff, 1 ); old = i; } } if( 511 - ew <= x && x <= 511 && 0 <= y && y <= eh ) { Lib_display_key( 511 - ew, 0, "終了", 2 ); break; } } } Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); }