行列から画像への複写

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

Syntax

C#
public static int fnFIE_mat_copy_to_img(
	FMATRIX_PTR a,
	FHANDLE hdst
)
Visual Basic
Public Shared Function fnFIE_mat_copy_to_img ( 
	a As FMATRIX_PTR,
	hdst As FHANDLE
) As Integer

Parameters

a
Type: fvalgcli..::..FMATRIX_PTR
コピー元行列
hdst
Type: fvalgcli..::..FHANDLE
コピー先画像 (type: uc8, s16, us16, float, double / ch: 1)

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAMパラメータ不正
F_ERR_INVALID_IMAGE不正な画像エラー
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

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

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_mat_copy_to_img()
        {
            var a = FMATRIX_PTR.Zero;
            var hdst = FHANDLE.Zero;

            try
            {
                const int height = 4;
                const int width = 3;

                a = api.fnFIE_mat_aalloc(height, width);
                hdst = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_UC8, 1, width, height);
                Assert.IsTrue(a != FMATRIX_PTR.Zero, "エラーが発生しました。");
                Assert.IsTrue(hdst != FHANDLE.Zero, "エラーが発生しました。");

                // コピーするデータ.
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        a[y, x] = y * 10 + x;
                    }
                }

                // 行列から画像へのコピー.
                int status = api.fnFIE_mat_copy_to_img(a, hdst);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // コピー後のデータ.
                UCHAR_PTR pdst = api.fnFIE_img_get_adrs(hdst);
                SIZE_T stride = api.fnFIE_img_get_step_as_bytes(hdst);
                for (int y = 0; y < height; y++)
                {
                    Console.Write("[{0}]", y);
                    for (int x = 0; x < width; x++)
                    {
                        Console.Write(" {0,2}", pdst[x]);
                    }
                    Console.WriteLine("");
                    pdst = pdst + stride;
                }
            }
            finally
            {
                a.Dispose();
                hdst.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_mat_copy_to_img()
        Dim a As FMATRIX_PTR = FMATRIX_PTR.Zero
        Dim hdst As FHANDLE = FHANDLE.Zero

        Try
            Const  height As Integer = 4
            Const  width As Integer = 3

            a = api.fnFIE_mat_aalloc(height, width)
            hdst = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_UC8, 1, width, height)
            Assert.IsTrue(a <> FMATRIX_PTR.Zero, "エラーが発生しました。")
            Assert.IsTrue(hdst <> FHANDLE.Zero, "エラーが発生しました。")

            ' コピーするデータ.
            For y As Integer = 0 To height - 1
                For x As Integer = 0 To width - 1
                    a(y, x) = y * 10 + x
                Next
            Next

            ' 行列から画像へのコピー.
            Dim status As Integer = api.fnFIE_mat_copy_to_img(a, hdst)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' コピー後のデータ.
            Dim pdst As UCHAR_PTR = api.fnFIE_img_get_adrs(hdst)
            Dim stride As SIZE_T = api.fnFIE_img_get_step_as_bytes(hdst)
            For y As Integer = 0 To height - 1
                Console.Write("[{0}]", y)
                For x As Integer = 0 To width - 1
                    Console.Write(" {0,2}", pdst(x))
                Next
                Console.WriteLine("")
                pdst = pdst + stride
            Next
        Finally
            a.Dispose()
            hdst.Dispose()
        End Try
    End Sub
End Class

See Also