チャイルド画像の確保(単一チャネル割り当て版)

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

Syntax

C#
public static FHANDLE fnFIE_img_child_alloc_single_ch(
	FHANDLE hroot,
	int ch,
	int offset_x,
	int offset_y,
	int width,
	int height
)
Visual Basic
Public Shared Function fnFIE_img_child_alloc_single_ch ( 
	hroot As FHANDLE,
	ch As Integer,
	offset_x As Integer,
	offset_y As Integer,
	width As Integer,
	height As Integer
) As FHANDLE

Parameters

hroot
Type: fvalgcli..::..FHANDLE
ルート画像のハンドル(チャイルド画像でも可)
ch
Type: System..::..Int32
チャイルド画像を割り当てる、ルート画像のチャネル(0≦ ch ≦(ルート画像のch数-1))
offset_x
Type: System..::..Int32
ルート座標系における、チャイルド領域左上x座標(0≦ offset_x ≦(ルート画像の幅 -1 - width ))
offset_y
Type: System..::..Int32
ルート座標系における、チャイルド領域左上y座標(0≦ offset_y ≦(ルート画像の高さ -1 - height ))
width
Type: System..::..Int32
チャイルド領域幅 (1≦ width ≦(ルート画像の幅 - offset_x ))
height
Type: System..::..Int32
チャイルド領域高さ(1≦ height ≦(ルート画像の高さ - offset_y ))

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

            int type = (int)f_imgtype.F_IMG_UC8;
            int channels = 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 画像生成.
                hroot = api.fnFIE_img_root_alloc(type, channels, width, height);
                Assert.IsTrue(hroot != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

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

                // パラメータ取得.
                {
                    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(child_channel == _channels, "チャネル数:期待値と一致しません.");
                    Assert.IsTrue(type == _type, "タイプ:期待値と一致しません.");
                    Assert.IsTrue(child_width == _width, "幅:期待値と一致しません.");
                    Assert.IsTrue(child_height == _height, "高さ:期待値と一致しません.");
                    Console.WriteLine("_step={0}", _step);
                }
            }
            finally
            {
                // オブジェクトの開放.
                hroot.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_alloc_single_ch()
        Dim hroot As FHANDLE = FHANDLE.Zero
        Dim hchild As FHANDLE = FHANDLE.Zero

        Dim type As Integer = CInt(f_imgtype.F_IMG_UC8)
        Dim channels 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 画像生成.
            hroot = api.fnFIE_img_root_alloc(type, channels, width, height)
            Assert.IsTrue(hroot <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

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

            ' パラメータ取得.
            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(child_channel = _channels, "チャネル数:期待値と一致しません.")
                Assert.IsTrue(type = _type, "タイプ:期待値と一致しません.")
                Assert.IsTrue(child_width = _width, "幅:期待値と一致しません.")
                Assert.IsTrue(child_height = _height, "高さ:期待値と一致しません.")
                Console.WriteLine("_step={0}", _step)
            End If
        Finally
            ' オブジェクトの開放.
            hroot.Dispose()
            hchild.Dispose()
        End Try
    End Sub
End Class

See Also