オブジェクトの複製

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static FHANDLE fnFIE_copy_object(
	FHANDLE hsrc
)
Visual Basic
Public Shared Function fnFIE_copy_object ( 
	hsrc As FHANDLE
) As FHANDLE

Parameters

hsrc
Type: fvalgcli..::..FHANDLE
複製元

Return Value

Type: FHANDLE
指定されたハンドルオブジェクトをコピーして返します。 異常終了時には IntPtr.Zero を返します。 ただし、本関数では画像オブジェクトは (ルート画像とチャイルド画像共に)コピーすることが出来ません。

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// オブジェクトのコピー. 
        /// </summary>
        /// <remarks>
        /// ただし、本関数では画像オブジェクトは (ルート画像とチャイルド画像共に)コピーすることが出来ません.
        /// </remarks>
        [FvPluginExecute]
        public void fnFIE_copy_object()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hsrc = FHANDLE.Zero;
            FHANDLE hdst = FHANDLE.Zero;
            UCHAR_PTR ptrn = UCHAR_PTR.Zero;

            int size_x = 3;
            int size_y = 3;
            int step_x = 3;
            int anchor_x = 1;
            int anchor_y = 1;

            try
            {
                // --構造要素の場合.
                //    ptrn = {
                //            0,0,0,
                //            0,1,0,
                //            0,0,0
                //            };

                ptrn = UCHAR_PTR.alloc(size_x * size_y);
                for (int i = 0; i < size_x * size_y; i++)
                {
                    if (i == 4)
                        ptrn[i] = 1;
                    else
                        ptrn[i] = 0;
                }

                // 構造要素オブジェクトの確保と構造要素の設定.
                hsrc = api.fnFIE_morphology_se_alloc(ptrn, size_x, size_y, step_x, anchor_x, anchor_y);

                // 処理の実行.
                hdst = api.fnFIE_copy_object(hsrc);

                // エラー判定.
                Assert.IsTrue(hdst != FHANDLE.Zero, "エラーが発生しました。({0})", (f_err)status);

                // 比較.
                {
                    int dst_size_x = 0;
                    int dst_size_y = 0;
                    int dst_anchor_x = 0;
                    int dst_anchor_y = 0;
                    status = api.fnFIE_morphology_get_params(hdst, ref dst_size_x, ref dst_size_y, ref dst_anchor_x, ref dst_anchor_y);
                    Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "Error. {0}", status);

                    Assert.IsTrue(size_x == dst_size_x && size_y == dst_size_y
                                && anchor_x == dst_anchor_x && anchor_y == dst_anchor_y, "期待値と一致しません");                     
                }
            }
            finally
            {
                // オブジェクトの開放.
                hsrc.Dispose();
                hdst.Dispose();
                ptrn.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' オブジェクトのコピー. 
    ''' </summary>
    ''' <remarks>
    ''' ただし、本関数では画像オブジェクトは (ルート画像とチャイルド画像共に)コピーすることが出来ません.
    ''' </remarks>
    <FvPluginExecute> _
    Public Sub fnFIE_copy_object()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hsrc As FHANDLE = FHANDLE.Zero
        Dim hdst As FHANDLE = FHANDLE.Zero
        Dim ptrn As UCHAR_PTR = UCHAR_PTR.Zero

        Dim size_x As Integer = 3
        Dim size_y As Integer = 3
        Dim step_x As Integer = 3
        Dim anchor_x As Integer = 1
        Dim anchor_y As Integer = 1

        Try
            ' --構造要素の場合.
            '    ptrn = {
            '            0,0,0,
            '            0,1,0,
            '            0,0,0
            '            };

            ptrn = UCHAR_PTR.alloc(size_x * size_y)
            For i As Integer = 0 To size_x * size_y - 1
                If i = 4 Then
                    ptrn(i) = 1
                Else
                    ptrn(i) = 0
                End If
            Next

            ' 構造要素オブジェクトの確保と構造要素の設定.
            hsrc = api.fnFIE_morphology_se_alloc(ptrn, size_x, size_y, step_x, anchor_x, anchor_y)

            ' 処理の実行.
            hdst = api.fnFIE_copy_object(hsrc)

            ' エラー判定.
            Assert.IsTrue(hdst <> FHANDLE.Zero, "エラーが発生しました。({0})", CType(status, f_err))

            ' 比較.
            If True Then
                Dim dst_size_x As Integer = 0
                Dim dst_size_y As Integer = 0
                Dim dst_anchor_x As Integer = 0
                Dim dst_anchor_y As Integer = 0
                status = api.fnFIE_morphology_get_params(hdst, dst_size_x, dst_size_y, dst_anchor_x, dst_anchor_y)
                Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "Error. {0}", status)

                Assert.IsTrue(size_x = dst_size_x AndAlso size_y = dst_size_y AndAlso anchor_x = dst_anchor_x AndAlso anchor_y = dst_anchor_y, "期待値と一致しません")
            End If
        Finally
            ' オブジェクトの開放.
            hsrc.Dispose()
            hdst.Dispose()
            ptrn.Dispose()
        End Try
    End Sub
End Class

See Also