//**********************************************
// 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


[ExportImage]
	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";

	return 0;

[ImportImage]
	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);
	}

[LoadImageIntoMatrix]
	// 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;

[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

