ファイル読み込み
Namespace: FVIL.DataAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public virtual void Load( string strFileName ) |
Visual Basic |
---|
Public Overridable Sub Load ( strFileName As String ) |
Parameters
- strFileName
- Type: System..::..String
ファイル名称
Implements
IFviFileAccess..::..Load(String)Remarks
指定されたファイルからデータを復元します。
通常は Save(String) メソッドで保存したファイルを指定してください。
それ以外で、何らかの画像ファイルが存在するとき、できる限り復元しようとしますが内容が正常とは限りません。
処理に失敗した場合は例外を発行します。
例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|---|---|
51 | FVIL.ErrorCode.LICENSE_ERROR | ライセンスキーが見つからない為、実行できません。 または、 FVIL._SetUp.InitVisionLibrary が実行されていません。 |
1 | FVIL.ErrorCode.FAILED_TO_ALLOCATE | メモリ不足の為、処理に失敗しました。 |
11 | FVIL.ErrorCode.INVALID_PARAMETER | パラメータが無効です。ファイル名に null や空白は指定できません。 |
21 | FVIL.ErrorCode.NOT_SUPPORTED | 指定されたファイル形式はサポートされていません。 |
23 | FVIL.ErrorCode.NOT_ALLOCATED | メモリが確保されていません。 |
Examples
ソースコード:
【関数の出力】
C# | Copy |
---|---|
// $Revision: 1.3 $ using System; using System.Collections.Generic; using System.Text; using fvalgcli; // FvPluginXXXX attribute requires fvalgcli namespace User.SampleCode { public partial class Matrix { /// <summary> /// ファイル入出力. /// </summary> [FvPluginExecute] public void FileIO() { Save(Defs.ResultDir + "/matrix.raw"); Console.WriteLine("\n"); Load(Defs.ResultDir + "/matrix.raw"); Console.WriteLine("\n"); } /// <summary> /// ファイル保存. /// </summary> public void Save(string savefile) { int rows = 3; int columns = 3; // 1) インスタンスの準備. FVIL.Data.CFviMatrix mat = new FVIL.Data.CFviMatrix(rows, columns); // 2) 行列の要素の設定. mat[0, 0] = 1.0; mat[0, 1] = 3.0; mat[0, 2] = 3.0; mat[1, 0] = 4.0; mat[1, 1] = -2.0; mat[1, 2] = 1.0; mat[2, 0] = 2.0; mat[2, 1] = 5.0; mat[2, 2] = -1.0; // 3) 実行. mat.Save(savefile); // 確認) 処理結果の出力. Console.Write("CFviMatrix.Save -> Success.\n"); } /// <summary> /// ファイル読み込み. /// </summary> public void Load(string loadfile) { int rows = 3; int columns = 3; // 1) インスタンスの準備. FVIL.Data.CFviMatrix mat = new FVIL.Data.CFviMatrix(rows, columns); // 2) 行列の要素の設定. // 3) 実行. mat.Load(loadfile); // 確認) 処理結果の出力. Console.Write("CFviMatrix.Load\n"); for (int row = 0; row < mat.Rows; row++) { for (int column = 0; column < mat.Columns; column++) { Console.Write("[{0}][{1}]={2} ", row, column, mat[row, column]); } Console.Write("\n"); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli ' FvPluginXXXX attribute requires fvalgcli Namespace SampleCode Public Partial Class Matrix ''' <summary> ''' ファイル入出力. ''' </summary> <FvPluginExecute> _ Public Sub FileIO() Save(Defs.ResultDir & "/matrix.raw") Console.WriteLine(vbLf) Load(Defs.ResultDir & "/matrix.raw") Console.WriteLine(vbLf) End Sub ''' <summary> ''' ファイル保存. ''' </summary> Public Sub Save(savefile As String) Dim rows As Integer = 3 Dim columns As Integer = 3 ' 1) インスタンスの準備. Dim mat As New FVIL.Data.CFviMatrix(rows, columns) ' 2) 行列の要素の設定. mat(0, 0) = 1.0 mat(0, 1) = 3.0 mat(0, 2) = 3.0 mat(1, 0) = 4.0 mat(1, 1) = -2.0 mat(1, 2) = 1.0 mat(2, 0) = 2.0 mat(2, 1) = 5.0 mat(2, 2) = -1.0 ' 3) 実行. mat.Save(savefile) ' 確認) 処理結果の出力. Console.Write("CFviMatrix.Save -> Success." & vbLf) End Sub ''' <summary> ''' ファイル読み込み. ''' </summary> Public Sub Load(loadfile As String) Dim rows As Integer = 3 Dim columns As Integer = 3 ' 1) インスタンスの準備. Dim mat As New FVIL.Data.CFviMatrix(rows, columns) ' 2) 行列の要素の設定. ' 3) 実行. mat.Load(loadfile) ' 確認) 処理結果の出力. Console.Write("CFviMatrix.Load" & vbLf) For row As Integer = 0 To mat.Rows - 1 For column As Integer = 0 To mat.Columns - 1 Console.Write("[{0}][{1}]={2} ", row, column, mat(row, column)) Next Console.Write(vbLf) Next End Sub End Class End Namespace |
CFviMatrix.Save -> Success. CFviMatrix.Load [0][0]=1 [0][1]=3 [0][2]=3 [1][0]=4 [1][1]=-2 [1][2]=1 [2][0]=2 [2][1]=5 [2][2]=-1
Exceptions
Exception | Condition |
---|---|
FVIL..::..CFviException | この例外の原因については、上記のエラーコード表をご参照ください。 |