PNGファイル読み込み

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

Syntax

C#
public static int fnFIE_load_core_png(
	string filename,
	FHANDLE hImg,
	ref int depth,
	F_IMG_CALLBACK handler,
	IntPtr vpData
)
Visual Basic
Public Shared Function fnFIE_load_core_png ( 
	filename As String,
	hImg As FHANDLE,
	ByRef depth As Integer,
	handler As F_IMG_CALLBACK,
	vpData As IntPtr
) As Integer

Parameters

filename
Type: System..::..String
読み込むPNGファイル名
hImg
Type: fvalgcli..::..FHANDLE
読み込み先ルート画像オブジェクトハンドル
depth
Type: System..::..Int32%
真のビット深度を保存するためのポインタ(省略時は IntPtr.Zero)
handler
Type: fvalgcli..::..F_IMG_CALLBACK
コールバック関数へのポインタ(省略時は IntPtr.Zero)
vpData
Type: System..::..IntPtr
コールバック関数の呼び出し時に渡される任意のポインタ(省略時は IntPtr.Zero)

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足エラー
F_ERR_INVALID_IMAGE画像オブジェクトの異常
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_FILE_IOPNGファイルのオープン失敗
F_ERR_UNSUPPORTED_IMAGE_FILE不正なPNGファイル
F_ERR_INTERRUPTED_IMAGE_IOユーザによって処理が中断された
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>
        /// PNGファイル読み込み.
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_load_core_png()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hroot1 = FHANDLE.Zero;
            FHANDLE hroot2 = FHANDLE.Zero;
            int type = (int)f_imgtype.F_IMG_UC8;
            int channels = 3;
            int width = 640;
            int height = 480;
            string fn = ResultDir + "/fnFIE_load_core_png.png";

            try
            {
                // root 画像生成.
                hroot1 = api.fnFIE_img_root_alloc(type, channels, width, height);
                Assert.IsTrue(hroot1 != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

                status = api.fnFIE_img_clear(hroot1, 255);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_clear: エラーが発生しました。({0})", (f_err)status);

                // PNGファイル保存.
                status = api.fnFIE_save_core_png(fn, hroot1, 9, -1, png_callback, FHANDLE.Zero);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_save_core_png: エラーが発生しました。({0})", (f_err)status);

                // PNGファイル内容確認.
                F_IMG_INFO img_info = new F_IMG_INFO();
                status = api.fnFIE_check_png_info(fn, f_color_img_type.F_COLOR_IMG_TYPE_UC8, ref img_info);

                // 読み込み用 root 画像生成.
                hroot2 = api.fnFIE_img_root_alloc((int)img_info.type, (int)img_info.channel, (int)img_info.width, (int)img_info.height);
                Assert.IsTrue(hroot2 != FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。");

                status = api.fnFIE_img_clear(hroot2, 0);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_clear: エラーが発生しました。({0})", (f_err)status);

                // PNGファイル読み込み.
                {
                    int depth = 0;
                    status = api.fnFIE_load_core_png(fn, hroot2, ref depth, png_callback, IntPtr.Zero);
                    Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_load_png: エラーが発生しました。({0})", (f_err)status);
                }

                bool result = false;
                status = api.fnFIE_img_compare(hroot1, hroot2, ref result);
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_img_compare: エラーが発生しました。({0})", (f_err)status);
                if (result == false)
                    Assert.IsTrue(false, "値が一致しません。");
            }
            finally
            {
                // オブジェクトの開放.
                hroot1.Dispose();
                hroot2.Dispose();
            }
        }

        bool png_callback(IntPtr vpData, double percentage)
        {
            Console.WriteLine("png_callback: percentage={0}", percentage);
            return true;
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE


    ''' <summary>
    ''' PNGファイル読み込み.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_load_core_png()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hroot1 As FHANDLE = FHANDLE.Zero
        Dim hroot2 As FHANDLE = FHANDLE.Zero
        Dim type As Integer = CInt(f_imgtype.F_IMG_UC8)
        Dim channels As Integer = 3
        Dim width As Integer = 640
        Dim height As Integer = 480
        Dim fn As String = ResultDir & "/fnFIE_load_core_png.png"

        Try
            ' root 画像生成.
            hroot1 = api.fnFIE_img_root_alloc(type, channels, width, height)
            Assert.IsTrue(hroot1 <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

            status = api.fnFIE_img_clear(hroot1, 255)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_clear: エラーが発生しました。({0})", CType(status, f_err))

            ' PNGファイル保存.
            status = api.fnFIE_save_core_png(fn, hroot1, 9, -1, AddressOf png_callback, FHANDLE.Zero)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_save_core_png: エラーが発生しました。({0})", CType(status, f_err))

            ' PNGファイル内容確認.
            Dim img_info As New F_IMG_INFO()
            status = api.fnFIE_check_png_info(fn, f_color_img_type.F_COLOR_IMG_TYPE_UC8, img_info)

            ' 読み込み用 root 画像生成.
            hroot2 = api.fnFIE_img_root_alloc(CInt(img_info.type), CInt(img_info.channel), CInt(img_info.width), CInt(img_info.height))
            Assert.IsTrue(hroot2 <> FHANDLE.Zero, "fnFIE_img_root_alloc: エラーが発生しました。")

            status = api.fnFIE_img_clear(hroot2, 0)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_clear: エラーが発生しました。({0})", CType(status, f_err))

            ' PNGファイル読み込み.
            If True Then
                Dim depth As Integer = 0
                status = api.fnFIE_load_core_png(fn, hroot2, depth, AddressOf png_callback, IntPtr.Zero)
                Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_load_png: エラーが発生しました。({0})", CType(status, f_err))
            End If

            Dim result As Boolean = False
            status = api.fnFIE_img_compare(hroot1, hroot2, result)
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_img_compare: エラーが発生しました。({0})", CType(status, f_err))
            If result = False Then
                Assert.IsTrue(False, "値が一致しません。")
            End If
        Finally
            ' オブジェクトの開放.
            hroot1.Dispose()
            hroot2.Dispose()
        End Try
    End Sub

    Private Function png_callback(vpData As IntPtr, percentage As Double) As Boolean
        Console.WriteLine("png_callback: percentage={0}", percentage)
        Return True
    End Function
End Class

See Also