Class ImageBufferExtensionsSystemDrawing

ImageBuffer を System.Drawing ライブラリと相互運用するための拡張メソッドを提供します。

継承

ImageBufferExtensionsSystemDrawing
Namespace: ic4
Assembly: ic4dotnet.System.Drawing.dll

構文

public static class ImageBufferExtensionsSystemDrawing

例

これらのメンバーは拡張メソッドであるため、明示的に呼び出すことも、まるでメンバ関数のようにイメージバッファ上で直接呼び出すこともできます。

メンバ関数として呼び出すには、ic4 名前空間に対する using ディレクティブが必要です。

using ic4;
// (...)
// どこかからイメージバッファを取得
ImageBuffer imageBuffer = GetImageBuffer();
// System.Drawing.Bitmap オブジェクトにコピーを作成
System.Drawing.Bitmap bmp = imageBuffer.CreateBitmapCopy();

推奨はされませんが、関数を明示的に呼び出すことも可能です。

// Get image buffer from somewhere
ImageBuffer imageBuffer = GetImageBuffer();
// Create copy in a System.Drawing.Bitmap object
System.Drawing.Bitmap bmp = imageBuffer.CreateBitmapCopy(imageBuffer);

メソッド

CreateBitmapCopy(ImageBuffer)

イメージバッファのコピーを作成し、Bitmap に格納します。

宣言

public static Bitmap CreateBitmapCopy(this ImageBuffer buffer)

パラメータ

型 名前 説明
ImageBuffer buffer イメージバッファ

戻り値

型 説明
Bitmap 渡されたイメージバッファの画像データのコピーを含む Bitmap

例外

型 条件
ArgumentNullException buffer が null の場合
NotSupportedException イメージバッファのピクセルフォーマットがサポートされていない場合

CreateBitmapWrap(ImageBuffer)

渡されたイメージバッファを Bitmap でラップします。

宣言

public static Bitmap CreateBitmapWrap(this ImageBuffer buffer)

パラメータ

型 名前 説明
ImageBuffer buffer イメージバッファ

戻り値

型 説明
Bitmap イメージバッファのメモリをピクセルストレージとして使用する Bitmap
備考

返される Bitmap は、イメージバッファが破棄されると無効になります。

例外

型 条件
ArgumentNullException buffer が null の場合
NotSupportedException イメージバッファのピクセルフォーマットのデータを Bitmap としてラップできない場合

IsBitmapWrapSupported(ImageBuffer)

CreateBitmapWrap(ImageBuffer) がイメージバッファのピクセルフォーマットで動作可能かどうかを確認します。

宣言

public static bool IsBitmapWrapSupported(this ImageBuffer buffer)

パラメータ

型 名前 説明
ImageBuffer buffer イメージバッファ

戻り値

型 説明
bool イメージバッファの内容を Bitmap としてラップできる場合は true、それ以外の場合は false
備考

イメージバッファの内容を Bitmap でラップできるのは、ピクセルフォーマットが以下のいずれかの場合のみです。

例外

型 条件
ArgumentNullException buffer が null の場合