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

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

Syntax

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

Parameters

hchild
Type: fvalgcli..::..FHANDLE
割り当てるチャイルド画像
hroot
Type: fvalgcli..::..FHANDLE
割り当てられるルート画像(チャイルド画像でも可)
ch
Type: System..::..Int32
チャイルド画像を割り当てる、ルート画像のチャネル(0≦ ch ≦(ルート画像のch数-1))
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.2 $

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

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFGA_img_child_attach_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 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, "fnFGA_img_root_alloc: エラーが発生しました。");

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

                // child 画像アタッチ(単一チャネル割り当て版).
                offset_x = 16;
                offset_y = 32;
                child_width = 200;
                child_height = 200;
                int status = fga.fnFGA_img_child_attach_single_ch(hchild, hroot, 2, offset_x, offset_y, child_width, child_height);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status, "fnFGA_img_child_attach_single_ch: エラーが発生しました。");

                // パラメータ取得.
                {
                    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, "高さ:期待値と一致しません.");
                }

                // child 画像デタッチ.
                status = fga.fnFGA_img_child_detach(hchild);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status, "fnFGA_img_child_detach: エラーが発生しました。");
                if (fga.fnFGA_img_get_adrs(hchild) != IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "fnFGA_img_child_detach: NULL になるべきです.");
            }
            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