int iip_scan::open( void )
{
	/*
	 * DLLロード、DSMのオープン、DSのオープン
	 */

	if (OK != this->state1to2()) { pri_funct_err_bttvr(
	 "Error : this->state1to2() returns NG." ); return NG; }
	if (OK != this->state2to3()) { pri_funct_err_bttvr(
	 "Error : this->state2to3() returns NG." ); return NG; }
	if (OK != this->state3to4()) { pri_funct_err_bttvr(
	 "Error : this->state3to4() returns NG." ); return NG; }

	/* TWAIN GUI画面使わないとき */
	if (OFF == this->_i_twain_gui_sw) {
	 /* GUIなしに対応しているかどうか調べる */
	 if (OK != this->cap_get_lp_uicontrollable_sw(
			 &(this->_l_uicontrollable_sw))) {
		pri_funct_err_bttvr(
	  "Error : this->cap_get_lp_uicontrollable_sw() returns NG." );
		return NG;
	 }

	 /* GUIなしに対応していないならエラーとする */
	 if (ON != this->_l_uicontrollable_sw) {
		pri_funct_err_bttvr(
  "Error : this->cap_get_lp_uicontrollable_sw(%ld is not ON).",
		   this->_l_uicontrollable_sw);
		return NG;
	 }
	}

	return OK;
}
/*
	スキャンラインフォーマット画像の、
	1スキャンライン分のみ、読み込む
	なお、
	Compression algorithm does not support random access.
	つまり、圧縮フォーマットの場合は、
	ゼロライン(yy=0)から順にとらないと読み込めない
	vp_scanlineは読み込み始める場所へのポインター
*/
int tif_read_scanline( TIF_IMAGE_RW *tp_read, uint32_t yy, void *vp_scanline )
{
	if (NULL == tp_read ) {
		pri_funct_err_bttvr(
			"Error : bad argument, tp_read is NULL." );
		return NG;
	}
	if (NULL == tp_read->tp_tiff_head ) {
		pri_funct_err_bttvr(
	"Error : bad argument, tp_read->tp_tiff_head is NULL." );
		return NG;
	}
	if (NULL == vp_scanline ) {
		pri_funct_err_bttvr(
			"Error : bad argument, vp_scanline is NULL." );
		return NG;
	}

	if ( -1 == TIFFReadScanline(
		tp_read->tp_tiff_head,
		/*(tdata_t)*/vp_scanline, yy, (tsample_t)0
	) ) {
		pri_funct_err_bttvr(
	  "Error : TIFFReadScanline(%p,%p,%u,0) returns minus.",
			tp_read->tp_tiff_head, vp_scanline, yy );
		return NG;
	}
	return OK;
}
int iip_scan::get_physical_param( void )
{
	/* 光学解像度を得る */
	if (OK != this->cap_get_dp_x_native_resolution(
			&(this->_d_x_native_resolution))) {
		pri_funct_err_bttvr(
	 "Error : this->cap_get_dp_x_native_resolution() returns NG." );
		return NG;
	}

	if (OK != this->cap_get_dp_y_native_resolution(
			&(this->_d_y_native_resolution))) {
		pri_funct_err_bttvr(
	 "Error : this->cap_get_dp_y_native_resolution() returns NG." );
		return NG;
	}

	/* 物理的な大きさを得る */
	if (OK != this->cap_get_dp_physical_width(
			&(this->_d_physical_width))) {
		pri_funct_err_bttvr(
	 "Error : this->cap_get_dp_physical_width() returns NG." );
		return NG;
	}
	if (OK != this->cap_get_dp_physical_height(
			&(this->_d_physical_height))) {
		pri_funct_err_bttvr(
	 "Error : this->cap_get_dp_physical_height() returns NG." );
		return NG;
	}

	return OK;
}
Exemple #4
0
/*** 2バイト単位読み込み ***/
int bread_ui16( BREAD *tp_, uint8_t *ui8p )
{
	int	i_1, i_2;

	if (NULL == tp_->_fp) {
		pri_funct_err_bttvr(
			"Error : Not fopen yet, at bread_ui16(-).");
		return NG;
	}

	i_1 = _bread_byte( tp_ );
	if (EOF == i_1) {
		pri_funct_err_bttvr(
			"Error : _bread_byte()<1st call> returns EOF.");
		return NG;
	}
	i_2 = _bread_byte( tp_ );
	if (EOF == i_2) {
		pri_funct_err_bttvr(
			"Error : _bread_byte()<2nd call> returns EOF.");
		return NG;
	}

	if (ON == tp_->_i_byte_swap_sw) {	/* x86 */
		ui8p[0] = (uint8_t)i_2;
		ui8p[1] = (uint8_t)i_1;
	}
	else {					/* 68x */
		ui8p[0] = (uint8_t)i_1;
		ui8p[1] = (uint8_t)i_2;
	}

	return OK;
}
Exemple #5
0
/* i32_incr is 1,2,3,... */
int bread_ui32array( BREAD *tp_, int32_t i32_size, uint8_t *ui8p, int32_t i32_incr )
{
	int32_t ii;

	if (NULL == tp_->_fp) {
		pri_funct_err_bttvr(
		"Error : Not fopen yet, bread_ui32array(-).");
		return NG;
	}
	if (i32_incr <= 0) {
		pri_funct_err_bttvr(
		"Error : bad argument i32_incr<%d>.", i32_incr);
		return NG;
	}

	for (ii = 0L; ii < i32_size; ++ii) {
		if (OK != bread_ui32( tp_, ui8p )) {
		pri_funct_err_bttvr(
		"Error : bread_ui32(-)<%d/%d call> returns NG.",
				ii, i32_size );
			return NG;
		}
		ui8p += 4 * i32_incr;
	}

	return OK;
}
int iip_scan::close( void )
{
	if (OK != this->state4to3()) { pri_funct_err_bttvr(
	 "Error : this->state4to3() returns NG." ); return NG; }
	if (OK != this->state3to2()) { pri_funct_err_bttvr(
	 "Error : this->state3to2() returns NG." ); return NG; }
	if (OK != this->state2to1()) { pri_funct_err_bttvr(
	 "Error : this->state2to1() returns NG." ); return NG; }
	return OK;
}
Exemple #7
0
int iip_precision::set_canvas( void )
{
	iip_canvas *clpp;

	clpp = this->get_clp_parent();

	/* pixelのchannel設定のチェック */
	if (OK != clpp->cl_ch_info.chk_e_ch_num_type()) {
		pri_funct_err_bttvr(
	 "Error : clpp->cl_ch_info.chk_e_ch_num_type() returns NG" );
		return NG;
	}
	if (OK != this->cl_ch_info.chk_e_ch_num_type()) {
		pri_funct_err_bttvr(
	 "Error : this->cl_ch_info.chk_e_ch_num_type() returns NG" );
		return NG;
	}

	/* 片方のみモノクロ2階調の画像は
	BW --> unsigned char Grayscaleを除いて処理できない
	両方モノクロ2階調の画像なら変換せず参照する
	*/
	if ((E_CH_NUM_BITBW == clpp->cl_ch_info.get_e_ch_num_type())
	&&  (E_CH_NUM_BITBW != this->cl_ch_info.get_e_ch_num_type())
	&&  (E_CH_NUM_UCHAR != this->cl_ch_info.get_e_ch_num_type())
	) {
		pri_funct_err_bttvr(
 "Error : only clpp->cl_ch_info.get_e_ch_num_type() is E_CH_NUM_BITBW");
		return NG;
	}
	if ((E_CH_NUM_BITBW != clpp->cl_ch_info.get_e_ch_num_type())
	&&  (E_CH_NUM_BITBW == this->cl_ch_info.get_e_ch_num_type())) {
		pri_funct_err_bttvr(
 "Error : only this->cl_ch_info.get_e_ch_num_type() is E_CH_NUM_BITBW");
		return NG;
	}

	/* 精度変化なし → 親キャンバスを参照(reference) */
	if (clpp->cl_ch_info.get_e_ch_num_type()
	==  this->cl_ch_info.get_e_ch_num_type()) {
		this->set_vp_reference_canvas(clpp->get_vp_canvas());
	}

	/* 精度変化あり → 親キャンバスからの変換(mem_alloc-->exec) */
	else {
		if (OK != this->mem_alloc_canvas()) {
			pri_funct_err_bttvr(
			"Error : this->mem_alloc_canvas() returns NG");
			return NG;
		}
	}

	return OK;
}
int iip_scan::set_icap_resolution_(void) {
	/* 読み取り解像度の設定 */
	if (OK != this->cap_set_d_x_resolution(this->_d_x_resolution)) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_x_resolution(-) return NG.");
		return NG;
	}
	if (OK != this->cap_set_d_y_resolution(this->_d_y_resolution)) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_y_resolution(-) return NG.");
		return NG;
	}
	return OK;
}
int iip_scan::read( void )
{
	HWND h_wnd = NULL;
	unsigned short us_show_ui = FALSE;
	unsigned short us_model_ui = FALSE;

	if (ON == this->_i_twain_gui_sw) {
		h_wnd = this->_hw_parent;
		us_show_ui = TRUE, 
		us_model_ui = TRUE;
	}

	if (OK != this->state4to5( h_wnd, us_show_ui, us_model_ui )) {
		pri_funct_err_bttvr(
	 "Error : this->state4to5() returns NG." ); return NG;
	}
	const int ret = this->state5to6to5event();
	if (NG == ret) { pri_funct_err_bttvr(
	 "Error : this->state5to6to5event() returns NG." ); return NG;
	}
	if (OK != this->state5to4()) { pri_funct_err_bttvr(
	 "Error : this->state5to4() returns NG." ); return NG;
	}

	if (NULL != this->_p_dib_bitmapinfo) {
		/* Nativeスキャンのときの画像情報 */
		this->_pri_bitmapinfoheader(
			&(this->_p_dib_bitmapinfo->bmiHeader)
		);
		if (ON == this->get_i_pv_sw()) {
			this->_pri_rgbquad( this->_p_dib_bitmapinfo );
		}

		/* DIB画像をiip_canvas画像に移設 */
		if (OK != this->_trans_image(
			this->_p_dib_bitmapinfo,
			&(this->_cl_iip_canvas)
		)) {
			pri_funct_err_bttvr(
		 "Error : this->_trans_image() returns NG." );
			return NG;
		}
	}

	if (ret == CANCEL) {
		return CANCEL;
	}
	return OK;
}
Exemple #10
0
/*** 読み込み位置の移動 ***/
int bread_seek( BREAD *tp_, long l_pos )
{
	if (NULL == tp_->_fp) {
		pri_funct_err_bttvr(
			"Error : Not fopen yet, at bread_seek(-).");
		return NG;
	}
	if (fseek(tp_->_fp, l_pos, SEEK_SET)) {
		pri_funct_err_bttvr(
		"Error : fseek(fp,po<%ld>,SEEK_SET) returns not zero.",
			l_pos);
		return NG;
	}
	return OK;
}
void gts_master::_change_view_main( void )
{
	/* データがないときはなにもしない */
	if (NULL == this->cl_iip_ro90.get_clp_parent()) {
		return;
	}

	/* 表示準備 */
	if (OK != this->_iipg_view_setup()) {
		pri_funct_err_bttvr(
	 "Error : this->_iipg_view_setup() returns NG" );
		return;
	}

	/* 画面の表示変更 */
	switch (this->cl_ogl_view.get_e_wview_type()) {
	case E_WVIEW_TYPE_NOTHING:
		break;
	case E_WVIEW_TYPE_MAIN:
		break;

	case E_WVIEW_TYPE_SUB:
	case E_WVIEW_TYPE_LR_PARALLEL:
	case E_WVIEW_TYPE_UD_PARALLEL:
	case E_WVIEW_TYPE_LR_ONION:
	case E_WVIEW_TYPE_UD_ONION:
		this->_wview_main();
		break;
	}

	/* 表示 */
	this->_iipg_view_redraw();
}
Exemple #12
0
/*** ファイルを開く ***/
int bread_open( char *cp_fname, BREAD *tp_ )
{
	if (NULL != tp_->_fp) {
		pri_funct_err_bttvr(
			"Error : file<%s> already opened.", cp_fname);
		return NG;
	}

	tp_->_fp = fopen( cp_fname, "rb" );
	if (NULL == tp_->_fp) {
		pri_funct_err_bttvr(
			"Error : fopen(%s,r) returns NULL.", cp_fname );
		return NG;
	}
	return OK;
}
Exemple #13
0
/* this->_i_next_list_numとthis->_i_next_file_numを設定する */
int list_access::set_next_number( void )
{
	char *cp_tmp;

	/* 01 選択されたフレームの次の順番を得る */
	this->_i_next_list_num = this->_next_selected(
	 this->_i_crnt_list_num + 1 );

	/* 02 次がなければ(無効)次のフレーム番号を無効にしてこのmethod終 */
	if (this->_i_next_list_num < 1) {
	    this->_i_next_file_num = -1;
		return OK;
	}

	/* 03 次の順番から、フレーム番号名を得る */
	cp_tmp = (char *)cl_gts_gui.selbro_fnum_list->text(
		this->_i_next_list_num);

	/* 04 選択されているのにフレーム番号名がない --> エラー */
	if (NULL == cp_tmp) {
		pri_funct_err_bttvr(
	"Error : cl_gts_gui.selbro_fnum_list->text(%d) returns NULL",
		this->_i_next_list_num
		);
		return NG;
	}

	/* 05 フレーム番号名からフレーム番号を得る */
	this->_i_next_file_num = atoi( cp_tmp );

	return OK;
}
Exemple #14
0
int list_access::marking_tgt( int i_num )
{
	char *cp_tmp, ca8_tmp[8];

	cp_tmp = (char *)cl_gts_gui.selbro_fnum_list->text(i_num);
	if (NULL == cp_tmp) {
		pri_funct_err_bttvr(
	 "Error : cl_gts_gui.selbro_fnum_list->text(%d) returns NULL",
		i_num
		);
		return NG;
	}

	if (4 == strlen(cp_tmp)) {
		/* "0001"のとき */
		(void)strcpy( ca8_tmp, cp_tmp );
		(void)strcat( ca8_tmp, " T" );
		cl_gts_gui.selbro_fnum_list->text(i_num, ca8_tmp);
	} else
	/* "0001 S" or "0001 T" */
	if (6 == strlen(cp_tmp)) {
		if ('S' == cp_tmp[5]) {
			/* "0001 S"のとき */
			(void)strcpy( ca8_tmp, cp_tmp );
			ca8_tmp[5] = 'S';
			ca8_tmp[6] = 'T';
			ca8_tmp[7] = '\0';
			cl_gts_gui.selbro_fnum_list->text(i_num, ca8_tmp);
		}
		/* "0001 T"ではなにもしない */
	}
	/* "0001 ST"ではなにもしない */

	return OK;
}
int tw_win_l2_dss::_cap_set_ctnr_onevalue( TW_UINT16 ui16_icap, TW_ONEVALUE tw_onevalue )
{
	TW_CAPABILITY	twCapability;
	pTW_ONEVALUE	p_tw_onevalue;

	/*
	www.twain.org/docs/Spec1_9_197.pdf
	 Page72,78
	 Chapter 4 -> Advenced Application Implementation
	 -> Capability -> Capability Negotiation -> Negotiation(Part 2)
	*/

	/* Step 1 : TW_CAPABILITY構造体の各値を設定 */
	twCapability.Cap = ui16_icap;
	twCapability.ConType = TWON_ONEVALUE;

	/* Step 2 : コンテナーメモリを確保し、値を設定
		GlobalAlloc(GHND,)は、移動可能メモリを確保し、
		確保したメモリの内容をゼロに初期化します。
		戻り値は、メモリオブジェクトのハンドルになります。
		ハンドルをポインタに変換するには、
		GlobalLock()関数を使用し、
		値を設定したのちGlobalUnlock()します。
	*/
	twCapability.hContainer = GlobalAlloc(GHND,sizeof(TW_ONEVALUE));
	if (NULL == twCapability.hContainer) {
		pri_funct_err_bttvr(
	"Error : GlobalAlloc(GHND,sizeof(TW_ONEVALUE)) returns NULL." );
		return NG;
	}
	p_tw_onevalue=(pTW_ONEVALUE)
	GlobalLock(twCapability.hContainer);
	*p_tw_onevalue = tw_onevalue; /* OneValueの設定 */
	GlobalUnlock(twCapability.hContainer);

	/* Step 3 : 送信し設定する
		(注)_cap_set_ctnr(-)の中で、 GlobalFree()してる
	*/
	if (OK!=this->_cap_set_ctnr(&twCapability)) {
		pri_funct_err_bttvr(
       "Error : this->_cap_set_ctnr(-) returns NG." );

		return NG;
	}

	return OK;
}
Exemple #16
0
/*** 基本読み込み関数(他の読み込み関数はすべてこの関数を使って読む) ***/
static int _bread_byte( BREAD *tp_ )
{
	int	i_;

	if ((FILE *)NULL == tp_->_fp) {
		pri_funct_err_bttvr(
			"Error : Not fopen yet, at _bread_byte(-).");
		return EOF;
	}

	/*
		fgetc()はunsigned charとして読みintにキャストして返す
		ISO 9899;1990(limits.h)では
			charは8ビット以上である
			intは16ビット以上である
		2004.06.24 wrote
	*/
	i_ = fgetc( tp_->_fp );
	if (EOF == i_) {
		/* バイナリデータなのでEOFが帰ってくるのは問題である */
		/***pri_funct_err_bttvr(
			"Error : fgets(0x%x) returns EOF.",
			(unsigned int)(tp_->_fp) );***/
		pri_funct_err_bttvr(
			"Error : fgets(0x%p) returns EOF.",
			tp_->_fp );
		/* 読み込みエラーのとき */
		if (ferror(tp_->_fp)) {
			pri_funct_err_bttvr(
	"Error : ferror(-) returns not zero, at _bread_byte(-)." );
		}
		/* バイナリデータの場合、
		   ファイルエンドを越えて読んではいけない */
		else if (feof(tp_->_fp)) {
		pri_funct_err_bttvr(
		"Error : feof(-) returns not zero, at _bread_byte(-).");
		}
		/* エラーでも、ファイルエンドでもないのに
		   EOFが帰ってきた?! */
		else {
			pri_funct_err_bttvr(
		"Error : but no error, not eof, at _bread_byte(-)" );
		}
	}
	return i_;
}
int iip_scan::set_icap_xfermech_(void) {
	/* TWAINでの画像受け取りの方法 */
	if (ON == this->_i_xfermech_memory_sw) {
		if (OK != this->cap_set_xfermech_memory()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_xfermech_memory(-) return NG.");
			return NG;
		}
	} else {
		if (OK != this->cap_set_xfermech_native()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_xfermech_native(-) return NG.");
			return NG;
		}
	}
	return OK;
}
void gts_master::_from_area_val_to_opengl_rect( void )
{
	double	d_cm_x,
		d_cm_y,
		d_cm_w,
		d_cm_h;
	long	l_image_h,
		l_pix_x,
		l_pix_y,
		l_pix_w,
		l_pix_h;
	double	d_dpi;

	/* 表示画像のサイズを得る */
	l_image_h = this->cl_ogl_view.get_l_height();

#if 0 /* ----------------------- commnet out ----------------------- */
	/* 画像を表示していないときは実行しない */
	if (0 == this->cl_ogl_view.is_main_canvas()) { return; }

	if (l_image_h <= 0L) {
		/* データがない(表示していない)ときはなにもしない  */
		return;
	}
#endif /* ----------------------- commnet out ----------------------- */

	/* menuから数値を得る */
	d_cm_x = cl_gts_gui.valinp_area_x_pos->value();
	d_cm_y = cl_gts_gui.valinp_area_y_pos->value();
	d_cm_w = cl_gts_gui.valinp_area_x_size->value();
	d_cm_h = cl_gts_gui.valinp_area_y_size->value();

	/* menuから解像度を得る(dot per inchs) */
	//d_dpi = cl_gts_gui.valinp_area_reso->value();
	d_dpi = this->cl_iip_scan.d_x_resolution();
	if (d_dpi <= 0.0) {
		pri_funct_err_bttvr(
	//"Error : cl_gts_gui.valinp_area_reso->value() returns <%g>",
	"Error : this->cl_iip_scan.d_x_resolution() returns <%g>",
			d_dpi);
		return;
	}

	/* cm単位をpixel単位に変換 */
	l_pix_x = (long)floor(d_cm_x * d_dpi / 2.54);
	l_pix_y = (long)floor(d_cm_y * d_dpi / 2.54);
	l_pix_w = (long)floor(d_cm_w * d_dpi / 2.54);
	l_pix_h = (long)floor(d_cm_h * d_dpi / 2.54);

	/* 座標系変換 srcは左下原点 --> tgtは左上原点 */
	l_pix_y = l_image_h - (l_pix_y + l_pix_h);

	/* エリアを変更 */
	this->cl_ogl_view.set_crop_area(l_pix_x,l_pix_y,l_pix_w,l_pix_h);

	/* 変更したので、再表示 */
	cl_gts_gui.opengl_view->redraw();
}
int iip_scan::set_icap_orientation_(void) {
	/* 画像の回転 */
	if (OK != this->cap_set_i_orientation( this->_i_orientation )) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_i_orientation(-) return NG.");
		return NG;
	}
	return OK;
}
int iip_scan::set_icap_gamma_(void) {
	/* ガンマ */
	if (OK != this->cap_set_d_gamma( this->_d_gamma )) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_gamma(-) return NG.");
		return NG;
	}
	return OK;
}
int iip_scan::set_icap_contrast_(void) {
	/* コントラスト */
	if (OK != this->cap_set_d_contrast( this->_d_contrast )) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_contrast(-) return NG.");
		return NG;
	}
	return OK;
}
int iip_scan::set_icap_brightness_(void) {
	/* 明るさ */
	if (OK != this->cap_set_d_brightness( this->_d_brightness )) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_brightness(-) return NG.");
		return NG;
	}
	return OK;
}
int iip_scan::set_icap_units_(void) {
	/* 数値の単位を設定 */
	if (ON == this->_i_units_centimeters_sw) {
		if (OK != this->cap_set_units_centimeters()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_units_centimeters() return NG."
			);
			return NG;
		}
	} else {
		if (OK != this->cap_set_units_inchs()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_units_inchs() return NG.");
			return NG;
		}
	}
	return OK;
}
int iip_scan::set_icap_threshold_(void) {
	/* bw時のしきい値の設定 */
	if (OK != this->cap_set_d_threshold( this->_d_threshold )) {
		pri_funct_err_bttvr(
	 "Error : this->cap_set_d_threshold(-) return NG.");
		return NG;
	}
	return OK;
}
/* get capability with container */
int tw_win_l2_dss::_cap_get_ctnr( TW_UINT16 ui16_cap, TW_CAPABILITY *p_tw_capability )
{
	TW_UINT16 rc;

	/*
	www.twain.org/docs/Spec1_9_197.pdf
	 Page71, 75
	 Chapter 4 -> Advenced Application Implementation
	 -> Capability -> Capability Negotiation -> Negotiation(Part 1)
	*/

	/* Step 1 : 初期値を設定 */
	p_tw_capability->Cap = ui16_cap;
	p_tw_capability->ConType = TWON_DONTCARE16;
	p_tw_capability->hContainer = NULL;

	/* Step 2,3 : 関数を実行し、値をとってくる */
	rc = this->ds_entry(
		DG_CONTROL,DAT_CAPABILITY,MSG_GET,
		(TW_MEMREF)p_tw_capability
	);

	/* Step 4 : 戻り値をチェックする。ノーサポート、あるいはエラー
		    なら、コンディションコードをチェックする */
	if (TWRC_SUCCESS != rc) {
		if (OK != this->ds_pri_error(
		"DG_CONTROL,DAT_CAPABILITY,MSG_GET", rc )) {
			pri_funct_err_bttvr(
		 "Error : this->ds_pri_error() returns NG" );
		}
		return NG;
	}

	/* コンテナにデータが確保されていない...
	前のチェックで引っかかっているはずなので、ここで引っかかる
	ということは、TWAIN プログラミングの実装に問題がある。 */
	if (NULL == p_tw_capability->hContainer) {
		pri_funct_err_bttvr(
	   "Error : p_tw_capability->hContainer is NULL." );
		return NG;
	}

	return OK;
}
int iip_scan::set_icap_pixeltype_(void) {
	/* ピクセルタイプの設定 */
	switch (this->_e_pixeltype) {
	case E_PIXELTYPE_BW:
		if (OK != this->cap_set_pixeltype_bw()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_pixeltype_bw(-) return NG.");
			return NG;
		}
		/****if (OK != this->cap_set_i_bitdepth(1)) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_i_bitdepth(1) return NG.");
			return NG;
		}***/
		break;
	case E_PIXELTYPE_GRAYSCALE:
		if (OK != this->cap_set_pixeltype_gray()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_pixeltype_gray(-) return NG.");
			return NG;
		}
		/****if (OK != this->cap_set_i_bitdepth(8)) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_i_bitdepth(8) return NG.");
			return NG;
		}***/
		break;
	case E_PIXELTYPE_RGB:
		if (OK != this->cap_set_pixeltype_rgb()) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_pixeltype_rgb(-) return NG.");
			return NG;
		}
		/***if (OK != this->cap_set_i_bitdepth(8)) {
			pri_funct_err_bttvr(
		 "Error : this->cap_set_i_bitdepth(8) return NG.");
			return NG;
		}***/
		break;
	default:
		assert(0);
	}
	return OK;
}
Exemple #27
0
int gts_master::_iipg_view_setup( int i_max_area_sw )
{
	int	i_sw;

	/* 大きさの違う画像を表示するのか? */
	i_sw = OFF;
	if (
	(0 == this->cl_ogl_view.is_main_canvas()) ||
	(this->cl_ogl_view.get_l_width() !=
	 this->cl_iip_ro90.get_l_width()) ||
	(this->cl_ogl_view.get_l_height() !=
	 this->cl_iip_ro90.get_l_height())
	) {
		i_sw = ON;
	}

	/* 親子接続、画像大きさ、表示チャンネル(R,G,B,A,RGB)設定 */
	if (OK != this->cl_ogl_view.set_imagedata(
		&(this->cl_iip_ro90), &(this->cl_iip_trac)
	)) {
		fl_alert( "Memory Error!(at view_setup)" );
		pri_funct_err_bttvr(
	 "Error : this->cl_ogl_view.set_imagedata(-) returns NG" );
		return NG;
	}

	/* 最大サイズの場合切抜きをするのでON、それ以外はOFF */
	if (ON == i_max_area_sw) {
		this->cl_ogl_view.set_crop_disp_sw(ON);
	} else if (OFF == i_max_area_sw) {
		this->cl_ogl_view.set_crop_disp_sw(OFF);
	}/* ONでもOFFでもないとき(-1)はなにもしない-->以前の状態 */

	/* 始めて、あるいは大きさの違う画像を表示するときは */
	if (ON == i_sw) {
		/* Viewport, orth2d, 画像データとのパラメータ計算 */
		this->cl_ogl_view.reshape_opengl(
			cl_gts_gui.image_view->w(),
			cl_gts_gui.image_view->h()
		);

		/* OpenGL表示エリアの設定、フルサイズ表示の設定 */
		this->cl_ogl_view.init_viewparam(
			cl_gts_gui.image_view->w(),
			cl_gts_gui.image_view->h()
		);

		/* スクロールバー */
		this->set_scrollbar();

		/* zoom値表示 */
		this->print_window_headline();
	}

	return OK;
}
Exemple #28
0
int tga_write_close( TGA_WRITE *tp_write )
{
	/* ファイルを閉じる */
	if (OK != bwrite_close( &(tp_write->t_bwrite) )) {
		pri_funct_err_bttvr(
	 "Error : bwrite_close(-) returns NG." );
		return NG;
	}
	return OK;
}
int tif_image_read_header(
char *cp_fname,
long *lp_width,
long *lp_height,
long *lp_channels,
long *lp_bytes,
long *lp_bits,
double *dp_dpi_x,
double *dp_dpi_y,
long *lp_tile_width,
long *lp_tile_height,
long *lp_how_to_compression,
long *lp_orientation )
{
	TIF_IMAGE_RW	t_read;

	/* ヘッダー初期化 */
	tif_init_rw_header( &t_read );

	/* ファイルを開く */
	if (OK != tif_read_open( cp_fname, &t_read )) {
		pri_funct_err_bttvr(
			"Error : tif_read_open(-) returns NG.");
		tif_read_close( &t_read );
		return NG;
	}

	/* ヘッダー情報を受け取る */
	*lp_width    = t_read.ui32_image_width; /* 幅 */
	*lp_height   = t_read.ui32_image_length; /* 高さ */
	*lp_channels = t_read.ui16_samples_per_pixel;
	*lp_bytes    = t_read.ui16_bits_per_sample/8;
	*lp_bits     = t_read.ui16_bits_per_sample;
	*dp_dpi_x = t_read.f_dpi_x;
	*dp_dpi_y = t_read.f_dpi_y;

	/* スキャンラインフォーマットのとき */
	if (0 == t_read.i_tile_sw) {
		*lp_tile_width  = 0;
		*lp_tile_height = 0;
	}
	/* タイルフォーマットである */
	else {
		*lp_tile_width  = t_read.ui32_tile_width;
		*lp_tile_height = t_read.ui32_tile_length;
	}

	*lp_how_to_compression = t_read.ui16_compression;
	*lp_orientation = t_read.ui16_orientation;

	/* ファイルを閉じる */
	tif_read_close( &t_read );

	return OK;
}
Exemple #30
0
/* メモリは、
なければ新規確保、大きさが同じなら流用、違うなら再確保する */
int gts_master::_iipg_rot90( iip_canvas *clp_parent, int i_rotate_per_90 )
{
	iip_rot90 *clp_ro90;
	long	l_sz_ro90_old, l_sz_ro90_new;

	if (ON == this->i_mv_sw()) {
		pri_funct_msg_ttvr( "gts_master::_iipg_rot90(-)" );
	}

	/* 画像処理用class */
	clp_ro90 = &(this->cl_iip_ro90);

	/* 接続先(scan or read)は変更する場合あるのでここでセット */
	clp_ro90->set_clp_parent(clp_parent);

	/* いままでの画像メモリの大きさ */
	l_sz_ro90_old =	clp_ro90->get_l_height() *
			clp_ro90->get_l_channels() *
			clp_ro90->get_l_scanline_channel_bytes();

	/* 親のサイズを元に設定をしなおし... */
	clp_ro90->set_canvas_size(clp_parent);

	/* ...回転角度を設定し... */
	switch (i_rotate_per_90) {
	case 0: clp_ro90->set_clockwork_000(); break;
	case 1: clp_ro90->set_clockwork_090(); break;
	case 2: clp_ro90->set_clockwork_180(); break;
	case 3: clp_ro90->set_clockwork_270(); break;
	}

	/* ...値を回転する */
	this->cl_iip_ro90.rot_canvas_size();

	/* 回転したあとの画像メモリの大きさ */
	l_sz_ro90_new =	clp_ro90->get_l_height() *
			clp_ro90->get_l_channels() *
			clp_ro90->get_l_scanline_channel_bytes();

	/* 必要な大きさが以前と違う場合はメモリ確保しなおし */
	if (l_sz_ro90_old != l_sz_ro90_new) {
		/* メモリの取りなおし */
		if (OK != this->cl_iip_ro90.mem_alloc_canvas()) {
			pri_funct_err_bttvr(
	"Error : this->cl_iip_ro90.mem_alloc_canvas() returns NG" );
	fl_alert( "Memory Error!(at rot90) ,Please Restart." );
			return NG;
		}
	}

	/* 回転実行 */
	this->cl_iip_ro90.exec();

	return OK;
}