画像コピー (FGA と FIE の相互変換)

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_copy(
	FHANDLE srcimg,
	FHANDLE dstimg
)
Visual Basic
Public Shared Function fnFGA_img_copy ( 
	srcimg As FHANDLE,
	dstimg As FHANDLE
) As Integer

Parameters

srcimg
Type: fvalgcli..::..FHANDLE
コピー元画像 (FGA 画像オブジェクト または FIE 画像オブジェクト)
dstimg
Type: fvalgcli..::..FHANDLE
コピー先画像 (FGA 画像オブジェクト または FIE 画像オブジェクト)

Return Value

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

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

Examples

C# Copy imageCopy
//    $Revision: 1.3 $

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_copy()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hfie_src = FHANDLE.Zero;
            FHANDLE hfie_dst = FHANDLE.Zero;
            FHANDLE hfga_dst = FHANDLE.Zero;    // FGA 用.

            try
            {
                // コピー元画像のロード.
                api.fnFIE_load_img_file(Defs.TestImageDir + "/testdata/lena256.bmp", ref hfie_src, f_color_img_type.F_COLOR_IMG_TYPE_UC8);

                // 入力画像の情報取得.
                int width = api.fnFIE_img_get_width(hfie_src);
                int height = api.fnFIE_img_get_height(hfie_src);
                int channels = api.fnFIE_img_get_channels(hfie_src);
                int type = api.fnFIE_img_get_type(hfie_src);

                // コピー先画像の確保.
                hfga_dst = fga.fnFGA_img_root_alloc(type, channels, width, height);
                hfie_dst = api.fnFIE_img_root_alloc(type, channels, width, height);

                // 処理の実行.(FIE → FGA)
                status = fga.fnFGA_img_copy(hfie_src, hfga_dst);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status, "エラーが発生しました。");

                // 入力画像の情報取得.
                if (api.fnFIE_img_get_width(hfie_src) != fga.fnFGA_img_get_width(hfga_dst))
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "幅が一致しません。");
                if (api.fnFIE_img_get_height(hfie_src) != fga.fnFGA_img_get_height(hfga_dst))
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "高さが一致しません。");
                if (api.fnFIE_img_get_channels(hfie_src) != fga.fnFGA_img_get_channels(hfga_dst))
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "チャネル数が一致しません。");
                if (api.fnFIE_img_get_type(hfie_src) != fga.fnFGA_img_get_type(hfga_dst))
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "画像型が一致しません。");

                // 処理の実行.(FGA → FIE)
                status = fga.fnFGA_img_copy(hfga_dst, hfie_dst);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status, "エラーが発生しました。");

                // 画像データの比較.
                bool agree = false;
                api.fnFIE_img_compare(hfie_src, hfie_dst, ref agree);
                if (!agree)
                    throw new FvException(f_err.F_ERR_INVALID_IMAGE, "画像データが一致しません。");
            }
            finally
            {
                // オブジェクトの開放.
                hfie_src.Dispose();
                hfie_dst.Dispose();
                hfga_dst.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