チャイルド画像をルート画像へ割り当てる

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

Syntax

C#
public static int fnFIE_img_child_attach(
	FHANDLE hchild,
	FHANDLE hroot,
	int x,
	int y,
	int width,
	int height
)
Visual Basic
Public Shared Function fnFIE_img_child_attach ( 
	hchild As FHANDLE,
	hroot As FHANDLE,
	x As Integer,
	y As Integer,
	width As Integer,
	height As Integer
) As Integer

Parameters

hchild
Type: fvalgcli..::..FHANDLE
割り当てるチャイルド画像
hroot
Type: fvalgcli..::..FHANDLE
割り当てられるれるルート画像(チャイルド画像でも可)
x
Type: System..::..Int32
領域左上x座標 (0≦ x ≦(ルート画像の幅 -1 - width ))
y
Type: System..::..Int32
領域左上y座標 (0≦ y ≦(ルート画像の高さ -1 - height ))
width
Type: System..::..Int32
領域幅 (1≦ width ≦(ルート画像の幅 - x ))
height
Type: System..::..Int32
領域高さ (1≦ height ≦(ルート画像の高さ- y ))

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足エラー
F_ERR_INVALID_IMAGE画像オブジェクトの異常
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

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>
        [FvPluginExecute]
        public void fnFIE_img_child_attach()
        {
            FHANDLE hroot1 = FHANDLE.Zero;
            FHANDLE hroot2 = FHANDLE.Zero;
            FHANDLE hchild = FHANDLE.Zero;

            int type_1 = (int)f_imgtype.F_IMG_UC8;
            int type_2 = (int)f_imgtype.F_IMG_UI32;
            int channels_1 = 3;
            int channels_2 = 3;
            int width = 640;
            int height = 480;
            int child_channel = 1;
            int offset_x = 10;
            int offset_y = 20;
            int child_width = 128;
            int child_height = 64;

            try
            {
                // root 画像生成.
                hroot1 = api.fnFIE_img_root_alloc(type_1, channels_1, width, height);
                Assert.IsTrue(hroot1 != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

                hroot2 = api.fnFIE_img_root_alloc(type_2, channels_2, width, height);
                Assert.IsTrue(hroot2 != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

                // child 画像生成.
                hchild = api.fnFIE_img_child_alloc_single_ch(hroot1, child_channel, offset_x, offset_y, child_width, child_height);
                Assert.IsTrue(hchild != FHANDLE.Zero, "fnFIE_img_child_alloc: エラーが発生しました。");

                // child 画像アタッチ.
                child_width = 64;
                child_height = 32;
                int status = api.fnFIE_img_child_attach(hchild, hroot2, 320, 240, child_width, child_height);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_child_attach: エラーが発生しました。({0})", (f_err)status);

                // 画像情報取得.
                {
                    int _channels = api.fnFIE_img_get_channels(hchild);
                    int _type = api.fnFIE_img_get_type(hchild);
                    int _width = api.fnFIE_img_get_width(hchild);
                    int _height = api.fnFIE_img_get_height(hchild);
                    SIZE_T _step = api.fnFIE_img_get_step(hchild);

                    Assert.IsTrue(channels_2 == _channels, "チャネル数:期待値と一致しません.");
                    Assert.IsTrue(type_2 == _type, "タイプ:期待値と一致しません.");
                    Assert.IsTrue(child_width == _width, "幅:期待値と一致しません.");
                    Assert.IsTrue(child_height == _height, "高さ:期待値と一致しません.");
                }

                // child 画像アタッチ(単一チャネル割り当て版).
                child_width = 200;
                child_height = 200;
                status = api.fnFIE_img_child_attach_single_ch(hchild, hroot1, 2, 16, 32, child_width, child_height);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_child_attach_single_ch: エラーが発生しました。({0})", (f_err)status);

                // パラメータ取得.
                {
                    int _channels = api.fnFIE_img_get_channels(hchild);
                    int _type = api.fnFIE_img_get_type(hchild);
                    int _width = api.fnFIE_img_get_width(hchild);
                    int _height = api.fnFIE_img_get_height(hchild);
                    SIZE_T _step = api.fnFIE_img_get_step(hchild);

                    Assert.IsTrue(1 == _channels, "チャネル数:期待値と一致しません.");
                    Assert.IsTrue(type_1 == _type, "タイプ:期待値と一致しません.");
                    Assert.IsTrue(child_width == _width, "幅:期待値と一致しません.");
                    Assert.IsTrue(child_height == _height, "高さ:期待値と一致しません.");
                }

                // child 画像デタッチ.
                status = api.fnFIE_img_child_detach(hchild);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_child_detach: エラーが発生しました。({0})", (f_err)status);
                Assert.IsTrue(api.fnFIE_img_get_adrs(hchild) == IntPtr.Zero, "NULL になるべきです.");
            }
            finally
            {
                // オブジェクトの開放.
                hroot1.Dispose();
                hroot2.Dispose();
                hchild.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

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

Public Partial Class FIE
    ''' <summary>
    ''' ルート画像へのチャイルド画像割り当て.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_img_child_attach()
        Dim hroot1 As FHANDLE = FHANDLE.Zero
        Dim hroot2 As FHANDLE = FHANDLE.Zero
        Dim hchild As FHANDLE = FHANDLE.Zero

        Dim type_1 As Integer = CInt(f_imgtype.F_IMG_UC8)
        Dim type_2 As Integer = CInt(f_imgtype.F_IMG_UI32)
        Dim channels_1 As Integer = 3
        Dim channels_2 As Integer = 3
        Dim width As Integer = 640
        Dim height As Integer = 480
        Dim child_channel As Integer = 1
        Dim offset_x As Integer = 10
        Dim offset_y As Integer = 20
        Dim child_width As Integer = 128
        Dim child_height As Integer = 64

        Try
            ' root 画像生成.
            hroot1 = api.fnFIE_img_root_alloc(type_1, channels_1, width, height)
            Assert.IsTrue(hroot1 <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

            hroot2 = api.fnFIE_img_root_alloc(type_2, channels_2, width, height)
            Assert.IsTrue(hroot2 <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

            ' child 画像生成.
            hchild = api.fnFIE_img_child_alloc_single_ch(hroot1, child_channel, offset_x, offset_y, child_width, child_height)
            Assert.IsTrue(hchild <> FHANDLE.Zero, "fnFIE_img_child_alloc: エラーが発生しました。")

            ' child 画像アタッチ.
            child_width = 64
            child_height = 32
            Dim status As Integer = api.fnFIE_img_child_attach(hchild, hroot2, 320, 240, child_width, child_height)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_child_attach: エラーが発生しました。({0})", CType(status, f_err))

            ' 画像情報取得.
            If True Then
                Dim _channels As Integer = api.fnFIE_img_get_channels(hchild)
                Dim _type As Integer = api.fnFIE_img_get_type(hchild)
                Dim _width As Integer = api.fnFIE_img_get_width(hchild)
                Dim _height As Integer = api.fnFIE_img_get_height(hchild)
                Dim _step As SIZE_T = api.fnFIE_img_get_step(hchild)

                Assert.IsTrue(channels_2 = _channels, "チャネル数:期待値と一致しません.")
                Assert.IsTrue(type_2 = _type, "タイプ:期待値と一致しません.")
                Assert.IsTrue(child_width = _width, "幅:期待値と一致しません.")
                Assert.IsTrue(child_height = _height, "高さ:期待値と一致しません.")
            End If

            ' child 画像アタッチ(単一チャネル割り当て版).
            child_width = 200
            child_height = 200
            status = api.fnFIE_img_child_attach_single_ch(hchild, hroot1, 2, 16, 32, child_width, _
                child_height)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_child_attach_single_ch: エラーが発生しました。({0})", CType(status, f_err))

            ' パラメータ取得.
            If True Then
                Dim _channels As Integer = api.fnFIE_img_get_channels(hchild)
                Dim _type As Integer = api.fnFIE_img_get_type(hchild)
                Dim _width As Integer = api.fnFIE_img_get_width(hchild)
                Dim _height As Integer = api.fnFIE_img_get_height(hchild)
                Dim _step As SIZE_T = api.fnFIE_img_get_step(hchild)

                Assert.IsTrue(1 = _channels, "チャネル数:期待値と一致しません.")
                Assert.IsTrue(type_1 = _type, "タイプ:期待値と一致しません.")
                Assert.IsTrue(child_width = _width, "幅:期待値と一致しません.")
                Assert.IsTrue(child_height = _height, "高さ:期待値と一致しません.")
            End If

            ' child 画像デタッチ.
            status = api.fnFIE_img_child_detach(hchild)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_child_detach: エラーが発生しました。({0})", CType(status, f_err))
            Assert.IsTrue(api.fnFIE_img_get_adrs(hchild) = IntPtr.Zero, "NULL になるべきです.")
        Finally
            ' オブジェクトの開放.
            hroot1.Dispose()
            hroot2.Dispose()
            hchild.Dispose()
        End Try
    End Sub
End Class

See Also