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

Namespace: fvalgcli
Assembly: fvalgcli_fga (in fvalgcli_fga.dll) Version: 3.1.0.0 (3.1.0.3)

Syntax

C#
public static FHANDLE fnFGA_img_child_alloc_single_ch(
	FHANDLE hroot,
	int ch,
	int offset_x,
	int offset_y,
	int width,
	int height
)
Visual Basic
Public Shared Function fnFGA_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
正常終了した場合は、確保されたチャイルド画像のハンドルを返します。 ライセンスエラー、未初期化エラー、パラメータ不正やメモリ確保失敗により異常終了した場合は、NULLを返します。

Examples

C# Copy imageCopy
//    $Revision: 1.2 $

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

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// チャイルド画像の確保(単一チャネル割り当て版).
        /// </summary>
        [FvPluginExecute]
        public void fnFGA_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 = fga.fnFGA_img_root_alloc(type, channels, width, height);
                if (hroot == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY, "エラーが発生しました。");

                // child 画像生成.
                hchild = fga.fnFGA_img_child_alloc_single_ch(hroot, child_channel, offset_x, offset_y, child_width, child_height);
                if (hchild == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY, "エラーが発生しました。");

                // パラメータ取得.
                {
                    int _channels = fga.fnFGA_img_get_channels(hchild);
                    int _type = fga.fnFGA_img_get_type(hchild);
                    int _width = fga.fnFGA_img_get_width(hchild);
                    int _height = fga.fnFGA_img_get_height(hchild);
                    SIZE_T _step = fga.fnFGA_img_get_step(hchild);

                    Console.WriteLine("_channels={0}", _channels);
                    Console.WriteLine("_type={0}", _type);
                    Console.WriteLine("_width={0}", _width);
                    Console.WriteLine("_height={0}", _height);
                    Console.WriteLine("_step={0}", _step.ToInt64());

                    if (1 != _channels)
                        throw new FvException(f_err.F_ERR_INVALID_IMAGE, "チャネル数:期待値と一致しません.");
                    if (type != _type)
                        throw new FvException(f_err.F_ERR_INVALID_IMAGE, "タイプ:期待値と一致しません.");
                    if (child_width != _width)
                        throw new FvException(f_err.F_ERR_INVALID_IMAGE, "幅:期待値と一致しません.");
                    if (child_height != _height)
                        throw new FvException(f_err.F_ERR_INVALID_IMAGE, "高さ:期待値と一致しません.");
                }
            }
            finally
            {
                // オブジェクトの開放.
                hroot.Dispose();
                hchild.Dispose();
            }
        }
    }
}

Exceptions

ExceptionCondition
System.IO..::..FileNotFoundException 実行環境に NVIDIA CUDA Runtime が存在しない場合、FGA ライブラリのロードが失敗し、この例外が発行されます。
必要な環境については FGA ライブラリ説明書 をご参照ください。
例外メッセージの例 (32bit 日本語 O/S の場合):
DLL 'fgamt.x86.3.0.0.dll' を読み込めません: 指定されたモジュールが見つかりません。 (HRESULT からの例外: 0x8007007E)

See Also