サイズ情報の取得 (WIL 用)

Namespace: FVIL.Ipl
Assembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)

Syntax

C#
public static ImageSize ToImageSize(
	IplImageSize size
)
Visual Basic
Public Shared Function ToImageSize ( 
	size As IplImageSize
) As ImageSize

Parameters

size
Type: FVIL.Ipl..::..IplImageSize
IplImage のサイズ情報

Return Value

Type: ImageSize
CFviImage を確保する際に使用するサイズ情報を返します。

Remarks

引数に指定された IplImage のサイズ情報と互換性がある画像オブジェクトのサイズ情報に変換します。
引数 size の width,height,channels が許容範囲内の場合は ImageSize にそのまま格納されます。
depth は下表のように変換されます。

対応表:
size.depth画像種別 (ImageType)
IPL_DEPTH_8UUC8
IPL_DEPTH_16SUS16
IPL_DEPTH_16US16
IPL_DEPTH_32SI32
IPL_DEPTH_32FFLOAT
IPL_DEPTH_64FDOUBLE

処理に失敗した場合は例外が発行されます。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。


エラーコード:
ErrorCode メンバ内容
16FVIL.ErrorCode.INVALID_IMAGETYPE対応する画像種別がありません。
17FVIL.ErrorCode.INVALID_IMAGESIZE幅、高さが許容範囲外です。
18FVIL.ErrorCode.INVALID_CHANNELチャネル数が許容範囲外です。

Examples

出力結果:
Copy imageCopy
HorzSize            : 93
VertSize            : 47
ImageType           : UC8
Channel             : 3
Depth               : 8
ImageInfo           : RGB


ソースコード:
C# Copy imageCopy
// $Revision: 1.3 $

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Reflection;

namespace SampleCode.Ipl
{
    partial class Converter
    {
        public static void ToImageSize1()
        {
            Console.WriteLine(MethodBase.GetCurrentMethod().Name);

            // 1) IplImageSize 構造体を初期化する.
            FVIL.Ipl.IplImageSize ipl_size;
            ipl_size.width = 93;
            ipl_size.height = 47;
            ipl_size.depth = (int)IPL_DEPTH.IPL_DEPTH_8U;
            ipl_size.channels = 3;

            // 2) 画像サイズ情報の取得.
            FVIL.ImageSize image_size = FVIL.Ipl.IplImageConverter.ToImageSize(ipl_size);

            // -) 確認.(任意)
            Console.WriteLine("{0,-20}: {1}", "HorzSize", image_size.HorzSize);
            Console.WriteLine("{0,-20}: {1}", "VertSize", image_size.VertSize);
            Console.WriteLine("{0,-20}: {1}", "ImageType", image_size.ImageType);
            Console.WriteLine("{0,-20}: {1}", "Channel", image_size.Channel);
            Console.WriteLine("{0,-20}: {1}", "Depth", image_size.Depth);
            Console.WriteLine("{0,-20}: {1}", "ImageInfo", image_size.ImageInfo);
        }
    }
}


Visual Basic Copy imageCopy
' $Revision: 1.2 $

Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports System.Reflection

Namespace Ipl
    Partial Class Converter
        Public Shared Sub ToImageSize1()
            Console.WriteLine(MethodBase.GetCurrentMethod().Name)

            ' 1) IplImageSize 構造体を初期化する.
            Dim ipl_size As FVIL.Ipl.IplImageSize
            ipl_size.width = 93
            ipl_size.height = 47
            ipl_size.depth = CInt(IPL_DEPTH.IPL_DEPTH_8U)
            ipl_size.channels = 3

            ' 2) 画像サイズ情報の取得.
            Dim image_size As FVIL.ImageSize = FVIL.Ipl.IplImageConverter.ToImageSize(ipl_size)

            ' -) 確認.(任意)
            Console.WriteLine("{0,-20}: {1}", "HorzSize", image_size.HorzSize)
            Console.WriteLine("{0,-20}: {1}", "VertSize", image_size.VertSize)
            Console.WriteLine("{0,-20}: {1}", "ImageType", image_size.ImageType)
            Console.WriteLine("{0,-20}: {1}", "Channel", image_size.Channel)
            Console.WriteLine("{0,-20}: {1}", "Depth", image_size.Depth)
            Console.WriteLine("{0,-20}: {1}", "ImageInfo", image_size.ImageInfo)
        End Sub
    End Class
End Namespace

Exceptions

ExceptionCondition
FVIL..::..CFviExceptionこの例外の原因については、上記のエラーコード表をご参照ください。

See Also