複数チャネル画像へのアンパッキング関数

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

Syntax

C#
public static int fnFGA_unpacking_ch(
	FHANDLE hsrc,
	FHANDLE hdst
)
Visual Basic
Public Shared Function fnFGA_unpacking_ch ( 
	hsrc As FHANDLE,
	hdst As FHANDLE
) As Integer

Parameters

hsrc
Type: fvalgcli..::..FHANDLE
入力画像 ( FGA 画像オブジェクト / type: uc8, s16, us16, double, float )
hdst
Type: fvalgcli..::..FHANDLE
出力画像 ( FGA 画像オブジェクト / type: uc8, s16, us16, double, float )

Return Value

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

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

Examples

C# Copy imageCopy
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFGA_unpacking_ch()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hfie_src = FHANDLE.Zero;    // 入力画像.
            FHANDLE hfie_dst = FHANDLE.Zero;    // 出力画像.
            FHANDLE hfga_src = FHANDLE.Zero;    // 入力画像.(FGA用)
            FHANDLE hfga_dst = FHANDLE.Zero;    // 出力画像.(FGA用)

            try
            {
                // 処理対象画像のロード.
                status = api.fnFIE_load_bmp(Defs.TestImageDir + "/testdata/fpm_pattern_cross.bmp", ref hfie_src, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 入力画像の情報取得.
                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);

                // 入力画像の生成.(FGA用)
                hfga_src = fga.fnFGA_img_root_alloc(type, channels, width, height);
                if (hfga_src == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // FIE 画像オブジェクトから FGA 画像オブジェクトへコピー.
                status = fga.fnFGA_img_copy(hfie_src, hfga_src);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 出力画像の生成.(FGA用)
                hfga_dst = fga.fnFGA_img_root_alloc(f_imgtype.F_IMG_UC8, 3, width / 3, height);
                if (hfga_dst == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // 処理の実行.
                status = fga.fnFGA_unpacking_ch(hfga_src, hfga_dst);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 出力画像の生成.
                hfie_dst = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_UC8, 3, width / 3, height);
                if (hfie_dst == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // FGA 画像オブジェクトから FIE 画像オブジェクトへコピー.
                status = fga.fnFGA_img_copy(hfga_dst, hfie_dst);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 処理結果画像の保存.
                // RGB各成分を独立した濃淡画像として保存.
                {
                    IntPtr[] adrs = new IntPtr[1];

                    SIZE_T step = api.fnFIE_img_get_step(hfie_dst);
                    int dst_width = api.fnFIE_img_get_width(hfie_dst);
                    int dst_height = api.fnFIE_img_get_height(hfie_dst);

                    for (int i = 0; i < 3; i++)
                    {
                        FHANDLE saveimg = FHANDLE.Zero;
                        try
                        {
                            adrs[0] = api.fnFIE_img_get_ch_adrs(hfie_dst, i);
                            saveimg = api.fnFIE_img_root_import_alloc(adrs, 1, f_imgtype.F_IMG_UC8, step, dst_width, dst_height);
                            status = api.fnFIE_save_png(Defs.ResultDir + string.Format("/fnFIE_unpacking_ch-{0}.png", i), saveimg, -1);
                            if (status != (int)f_err.F_ERR_NONE)
                                throw new FvException(status);
                        }
                        finally
                        {
                            saveimg.Dispose();
                        }
                    }
                }
            }
            finally
            {
                // オブジェクトの開放.
                hfie_src.Dispose();
                hfie_dst.Dispose();
                hfga_src.Dispose();
                hfga_dst.Dispose();
            }
        }
    }
}

See Also