//**********************************************
// Filename:	ImgFile.OGS
// Creation:	8/10/00 by CPY
// Copyright (c) OriginLab Corporation 1992-2000
// Purpose:	Image Import and Export scripts for Matrix
//**********************************************
// Modification Log:
// CPY v6.1018 8/10/00 MOVE_IMAGE_IMPORT_EXPORT, moved codes here from file.ogs
// EJP 04-30-2004 v7.5838 QA70-6347 INFORM_USER_ON_IMAGE_IMPORT_ERROR
// EJP 2005-07-15 v8.0268 QA70-7891 ACCESS_LEADTOOLS_FROM_OC
// EJP 2006-12-08 v8.0521 MAT_CONTEXT_MENU
/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
/// Folger 07/21/09 QA80-13980 SUPPORT_INSERT_IMAGE_INTO_GRAPH_AT_ANY_POSITION
/// Kenny 09/11/2009 INSERT_IMAGE_RESET_FNAME_IF_CALL_FROM_GUI_MENU

[ExportImage]
	// EJP 2006-12-08 v8.0521 MAT_CONTEXT_MENU
	/*
	run.section(file,Init);
	FDlog.CheckName$=$DialogBox.ExportImage;
	FDlog.CheckStatus=Image.ShowOptions;
	FDLOG.default$=%H;
	FDlog.UseGroup(Image);
	Image.GetExtList(z,em);
	FDlog.UseType(%z);
	if(FDlog.SaveAs(a))
		return 1;
	Image.ShowOptions=FDlog.CheckStatus;
	%z=FDlog.DefTypeExt$;
	%B=FDLOG.path$;
	Image.FileName$=%b%a;
	//%Z=;
	err = image.export.matrix(%H, %Z);
	if(err == 0)
		type "%H is exported into %B%A";
	else
		type -b "Error $(err) occurred when exporting %H";
	*/
	/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//expImage -d;
	run -xf expImage -d;
	/// END LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	/// end MAT_CONTEXT_MENU
	return 0;

[ImportImage]
	/// EJP 2005-07-15 v8.0268 QA70-7891 ACCESS_LEADTOOLS_FROM_OC
	/*
	Image.GetExtList(z,im);
	image.filedlg.filetypes$=%Z;
	if(Image.FileDlg.Open(Z))
		return 1;
	Image.FileName$="%Z";
	if(exist(%H)==5)
	{
		run.section(,LoadImageIntoMatrix);
	}
	else
	{
		run.section(,LoadImageIntoGrObject);
	}
	*/
	/// EJP 2006-12-08 v8.0521 MAT_CONTEXT_MENU
	///run.LoadOC(OriginLab\image_utils);
	///return image_dlg_import_to_active_page();
	/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//impImage -d;
	run -xf impImage -d;
	/// END LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	return 0;
	/// end MAT_CONTEXT_MENU
	/// end ACCESS_LEADTOOLS_FROM_OC

[LoadImageIntoMatrix]
	/// EJP 2005-07-15 v8.0268 QA70-7891 ACCESS_LEADTOOLS_FROM_OC
	/*
	// import into matrix
	// assume file name in Image.FileName$
	// load image into matrix and set window title
	// to see time to take for import, turn @B=1
	#!sec;
	err=image.import.matrix(%H);
	#!watch;
	if(err==0)
	{
		page.label$=Image.FileName$;
		page.title = 3;// show name + label
		matrix -ii;//show as image

		/// EJP 07-22-2003 v7.0631 QA70-4745 SET_PAGE_IMPORT_INFO_ON_123_ASC_IMPORT
		set_binary_import_page_info(Image.FileName$);
		/// end SET_PAGE_IMPORT_INFO_ON_123_ASC_IMPORT
	}
	/// EJP 04-30-2004 v7.5838 QA70-6347 INFORM_USER_ON_IMAGE_IMPORT_ERROR
	else
		type "Error $(err), LibError $(image.liberror)";
	/// end INFORM_USER_ON_IMAGE_IMPORT_ERROR
	return 0;
	*/
	run.LoadOC(OriginLab\image_utils);
	return image_import_to_active_matrix(Image.FileName$);
	/// end ACCESS_LEADTOOLS_FROM_OC

[LoadImageIntoGrObject]
	// import image into graphic object
	// assume file name in Image.FileName$
	// load image into matrix and set window title
	// to see time to take for import, turn @B=1
	#!sec;
	err=image.import.object(%H);
	#!watch;
	/// EJP 04-30-2004 v7.5838 QA70-6347 INFORM_USER_ON_IMAGE_IMPORT_ERROR
	if( err )
		type "Error $(err), LibError $(image.liberror)";
	/// end INFORM_USER_ON_IMAGE_IMPORT_ERROR

[ImportMultipleImages]
	run.LoadOC(OriginLab\Image);
	err = ImportMultipleImages(%H);
	return err;	

///------ Folger 07/21/09 QA80-13980 SUPPORT_INSERT_IMAGE_INTO_GRAPH_AT_ANY_POSITION
[InsertImagesFromFiles]
	/// Kenny 09/11/2009 INSERT_IMAGE_RESET_FNAME_IF_CALL_FROM_GUI_MENU
	//run -xf insertImg2g x:=%1 y:=%2;
	run -xf insertImg2g -dm x:=%1 y:=%2;
	/// End INSERT_IMAGE_RESET_FNAME_IF_CALL_FROM_GUI_MENU
///------ End SUPPORT_INSERT_IMAGE_INTO_GRAPH_AT_ANY_POSITION