RAW画像読込

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

Syntax

C#
public static int fnFIE_load_raw(
	string filename,
	ref FHANDLE himg,
	int type,
	int byte_order,
	int byte_step,
	int width,
	int height,
	SIZE_T header_sz
)
Visual Basic
Public Shared Function fnFIE_load_raw ( 
	filename As String,
	ByRef himg As FHANDLE,
	type As Integer,
	byte_order As Integer,
	byte_step As Integer,
	width As Integer,
	height As Integer,
	header_sz As SIZE_T
) As Integer

Parameters

filename
Type: System..::..String
読み込む画像ファイル名
himg
Type: fvalgcli..::..FHANDLE%
読込先画像のハンドラ
type
Type: System..::..Int32
RAW画像ファイルの画像タイプ
  • F_IMG_BIN : 2値画像(32bitパッキング)
  • F_IMG_UC8 : 濃淡8bit画像
  • F_IMG_S16 : 濃淡符号付き16bit画像
  • F_IMG_US16 : 濃淡16bit画像
  • F_IMG_I32 : 濃淡符号付き32bit画像
  • F_IMG_UI32 : 濃淡32bit画像
  • F_IMG_I64 : 濃淡符号付き64bit画像
  • F_IMG_FLOAT : 濃淡単精度浮動小数点画像
  • F_IMG_DOUBLE : 濃淡倍精度浮動小数点画像
  • F_IMG_RGBQUAD : RGBQUADの配列で表される、8bitカラー画像
  • F_IMG_RGBTRIPLE : 24bitパッキングカラー画像
byte_order
Type: System..::..Int32
RAW画像のバイトオーダー (0: Little Endian, 1: Big Endian)
byte_step
Type: System..::..Int32
RAW画像ファイルの1行ステップ(バイト数)
width
Type: System..::..Int32
RAW画像ファイルの画像幅
height
Type: System..::..Int32
RAW画像ファイルの画像高さ
header_sz
Type: fvalgcli..::..SIZE_T
RAW画像のヘッダサイズ(byte単位)

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足エラー
F_ERR_INVALID_IMAGE画像オブジェクトの異常
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_FILE_IOファイルI/Oエラー
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

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

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// RAW画像読込.
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_load_raw()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hroot1 = IntPtr.Zero;    // 画像の読込用.
            FHANDLE hroot2 = IntPtr.Zero;    // 画像の保存用.
            FHANDLE hroot3 = IntPtr.Zero;    // 画像の再読込用.

            string fn = ResultDir + "/fnFIE_load_raw.raw";
            int type = (int)f_imgtype.F_IMG_DOUBLE;

            try
            {
                // rawファイルの読込.
                status = api.fnFIE_load_raw(TestImageDir + "/testdata/fie_fft_img2.raw", ref hroot1, type, 0, sizeof(Double) * 64 * 2, 64 * 2, 32, new IntPtr(0));
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_load_raw: エラーが発生しました。({0})", (f_err)status);

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

                hroot2 = api.fnFIE_img_root_alloc(type, channels, width, height);
                Assert.IsTrue(hroot2 != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

                // データのコピー.
                status = api.fnFIE_img_copy(hroot1, hroot2);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_clear: エラーが発生しました。({0})", (f_err)status);

                // rawファイルの保存.
                status = api.fnFIE_save_raw(fn, hroot2, IntPtr.Zero, IntPtr.Zero);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_save_raw: エラーが発生しました。({0})", (f_err)status);

                // 保存画像情報取得.
                width = api.fnFIE_img_get_width(hroot2);
                height = api.fnFIE_img_get_height(hroot2);
                channels = api.fnFIE_img_get_channels(hroot2);

                // いったん保存したrawファイルの読込.
                status = api.fnFIE_load_raw(fn, ref hroot3, type, 0, width * 8, width, height, new IntPtr(0));
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_load_raw(再読込): エラーが発生しました。({0})", (f_err)status);

                // 元の画像との比較.
                bool result = false;
                status = api.fnFIE_img_compare(hroot3, hroot1, ref result);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_compare: エラーが発生しました。({0})", (f_err)status);
                Assert.IsTrue(result, "値が一致しません。");
            }
            finally
            {
                hroot1.Dispose();
                hroot2.Dispose();
                hroot3.Dispose();

            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Runtime.InteropServices
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' RAW画像読込.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_load_raw()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hroot1 As FHANDLE = IntPtr.Zero
        ' 画像の読込用.
        Dim hroot2 As FHANDLE = IntPtr.Zero
        ' 画像の保存用.
        Dim hroot3 As FHANDLE = IntPtr.Zero
        ' 画像の再読込用.
        Dim fn As String = ResultDir & "/fnFIE_load_raw.raw"
        Dim type As Integer = CInt(f_imgtype.F_IMG_DOUBLE)

        Try
            ' rawファイルの読込.
            status = api.fnFIE_load_raw(TestImageDir & "/testdata/fie_fft_img2.raw", hroot1, type, 0, Marshal.SizeOf(GetType(Double)) * 64 * 2, 64 * 2, _
                32, New IntPtr(0))
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_load_raw: エラーが発生しました。({0})", CType(status, f_err))

            '入力画像情報取得.
            Dim width As Integer = api.fnFIE_img_get_width(hroot1)
            Dim height As Integer = api.fnFIE_img_get_height(hroot1)
            Dim channels As Integer = api.fnFIE_img_get_channels(hroot1)

            hroot2 = api.fnFIE_img_root_alloc(type, channels, width, height)
            Assert.IsTrue(hroot2 <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

            ' データのコピー.
            status = api.fnFIE_img_copy(hroot1, hroot2)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_clear: エラーが発生しました。({0})", CType(status, f_err))

            ' rawファイルの保存.
            status = api.fnFIE_save_raw(fn, hroot2, IntPtr.Zero, IntPtr.Zero)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_save_raw: エラーが発生しました。({0})", CType(status, f_err))

            ' 保存画像情報取得.
            width = api.fnFIE_img_get_width(hroot2)
            height = api.fnFIE_img_get_height(hroot2)
            channels = api.fnFIE_img_get_channels(hroot2)

            ' いったん保存したrawファイルの読込.
            status = api.fnFIE_load_raw(fn, hroot3, type, 0, width * 8, width, _
                height, New IntPtr(0))
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_load_raw(再読込): エラーが発生しました。({0})", CType(status, f_err))

            ' 元の画像との比較.
            Dim result As Boolean = False
            status = api.fnFIE_img_compare(hroot3, hroot1, result)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_compare: エラーが発生しました。({0})", CType(status, f_err))
            Assert.IsTrue(result, "値が一致しません。")
        Finally
            hroot1.Dispose()
            hroot2.Dispose()

            hroot3.Dispose()
        End Try
    End Sub
End Class

See Also