JavaTM 2 Platform
Std. Ed. v1.3

java.awt.image
クラス Raster

java.lang.Object
  |
  +--java.awt.image.Raster
直系の既知のサブクラス:
WritableRaster

public class Raster
extends Object

ピクセルで構成される矩形配列を表現するクラスです。Raster は、サンプル値が格納されている DataBuffer と、指定されたサンプル値を DataBuffer から探し出す方法が記述されている SampleModel をカプセル化します。

Raster は、平面上の特定の矩形領域 (必ずしも (0, 0) を含んでいなくてもよい) を占めるピクセル値を定義します。この矩形は、Raster の境界の矩形といい、getBounds メソッドにより取得され、minX、minY、width、height の値によって定義されます。minX と minY の値は、Raster の左上隅の座標を定義します。境界の矩形外のピクセルを参照すると、例外がスローされたり、DataBuffer に関連している Raster の意図しない要素が参照されることになります。Raster を使用するときは、このような範囲外のアクセスは行わないようにしてください。

SampleModel は、Raster のサンプルが DataBuffer のプリミティブ配列要素に格納される方法を記述します。サンプルは、PixelInterleavedSampleModel や BandedSampleModel のようにデータ要素ごとに 1 つずつ格納することも、SinglePixelPackedSampleModel や MultiPixelPackedSampleModel のように複数の要素を 1 つにまとめて格納することもできます。SampleModel は、サンプルが符号付き拡張形式かどうかも制御します。これにより、符号なしデータを byte、short、int など Java の符号付きデータ型として格納できます。

Raster は平面上のどこにでも存在できますが、SampleModel は (0, 0) から始まる簡易座標体系を利用します。このため、Raster は、Raster の座標体系と SampleModel の座標体系の間でピクセル位置をマッピングできるようにする変換因子を持っています。SampleModel の座標体系から Raster の座標体系への変換は、getSampleModelTranslateX メソッドと getSampleModelTranslateY メソッドによって取得できます。

Raster はほかの Raster と DataBuffer を共有できますが、このためには、このような Raster を明示的に作成するか、createChild メソッドと createTranslatedChild メソッドを使用します。これらのメソッドによって作成された Raster に対して getParent メソッドを使用すると、作成側 Raster への参照を取得できます。createTranslatedChild や createChild の呼び出しによって作成された Raster でない場合、getParent は null を返します。

createTranslatedChild メソッドは、現在の Raster のすべてのデータを共有する新しい Raster を返します。新しい Raster は、現在の Raster と同じ幅と高さの境界の矩形を占めますが、始点は異なります。たとえば、親の Raster が (10, 10) から (100, 100) までの領域を占める場合、変換後の Raster の領域の始点を (50, 50) に定義したときは、親のピクセル (20, 20) と子のピクセル (60, 60) はこれら 2 つの Raster で共有される DataBuffer で同じ位置を占めます。対応する SampleModel 座標を取得するには、前者の場合はピクセル座標に (-10, -10) が加算されるのに対し、後者の場合は (-50, -50) が加算されます。

Raster の親子間の変換は、親の sampleModelTranslateX と sampleModelTranslateY の値から、子の sampleModelTranslateX と sampleModelTranslateY の値を減算することにより判定できます。

createChild メソッドを使うと、親の境界の矩形 (同じ座標体系または変換後の座標体系を持つ) のサブセットのみを占める新しい Raster や、親のバンドのサブセットを持つ新しい Raster を作成できます。

コンストラクタはすべて protected です。Raster を作成する方法としては、このクラスで定義されている static な create メソッドの 1 つを使うのが正しい方法です。これらのメソッドを使うと、標準のインタリーブ化された SampleModel、バンド化された SmpleModel、およびパックされた SampleModel を使う Raster のインスタンスが生成され、外部で生成された SampleModel と DataBuffer を結合して作成される場合と比べて効率的に処理できます。

関連項目:
DataBuffer, SampleModel, PixelInterleavedSampleModel, BandedSampleModel, SinglePixelPackedSampleModel, MultiPixelPackedSampleModel

フィールドの概要
protected  DataBuffer dataBuffer
          イメージデータを格納する DataBuffer です。
protected  int height
          この Raster の高さです。
protected  int minX
          この Raster の左上隅のピクセルの X 座標です。
protected  int minY
          この Raster の左上隅のピクセルの Y 座標です。
protected  int numBands
          Raster 内のバンド数です。
protected  int numDataElements
          1 ピクセル当たりの DataBuffer データ要素の数です。
protected  Raster parent
          この Raster の親、または null です。
protected  SampleModel sampleModel
          この Raster のピクセルが DataBuffer に格納される方法を記述する SampleModel です。
protected  int sampleModelTranslateX
          Raster の SampleModel の座標空間から Raster の座標空間への X 変換です。
protected  int sampleModelTranslateY
          Raster の SampleModel の座標空間から Raster の座標空間への Y 変換です。
protected  int width
          この Raster の幅です。
 
コンストラクタの概要
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)
          指定された SampleModel と DataBuffer を持つ Raster を構築します。
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, Raster parent)
          指定された SampleModel、DataBuffer、および親を持つ Raster を構築します。
protected Raster(SampleModel sampleModel, Point origin)
          指定された SampleModel を持つ Raster を構築します。
 
メソッドの概要
static WritableRaster createBandedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
          指定された DataBuffer、幅、高さ、走査線ストライド、バンクインデックス、およびバンクオフセットを持つ、BandedSampleModel に基づいた Raster を作成します。
static WritableRaster createBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
          指定されたデータタイプ、幅、高さ、走査線ストライド、バンクインデックス、およびバンドオフセットを持つ、BandedSampleModel に基づいた Raster を作成します。
static WritableRaster createBandedRaster(int dataType, int w, int h, int bands, Point location)
          指定されたデータタイプ、幅、高さ、およびバンド数を持つ、BandedSampleModel に基づいた Raster を作成します。
 Raster createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
          この Raster の DataBuffer のすべてまたは一部を共有する新しい Raster を返します。
 WritableRaster createCompatibleWritableRaster()
          この Raster と同じ SampleModel と初期化された新しい DataBuffer を持つ、この Raster と同じサイズで互換性のある WritableRaster を作成します。
 WritableRaster createCompatibleWritableRaster(int w, int h)
          指定されたサイズ、新しい SampleModel、初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。
 WritableRaster createCompatibleWritableRaster(int x, int y, int w, int h)
          指定された位置 (minX, minY) とサイズ (width, height)、新しい SampleModel、および初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。
 WritableRaster createCompatibleWritableRaster(Rectangle rect)
          rect によって指定される位置 (minX, minY) とサイズ (width, height)、新しい SampleModel、および初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。
static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
          指定された DataBuffer、幅、高さ、走査線ストライド、ピクセルストライド、およびバンドオフセットを持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。
static WritableRaster createInterleavedRaster(int dataType, int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets, Point location)
          指定されたデータタイプ、幅、高さ、走査線ストライド、ピクセルストライド、およびバンドオフセットを持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。
static WritableRaster createInterleavedRaster(int dataType, int w, int h, int bands, Point location)
          指定されたデータタイプ、幅、高さ、およびバンド数を持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。
static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int[] bandMasks, Point location)
          指定された DataBuffer、幅、高さ、走査線ストライド、およびバンドマスクを持つ、SinglePixelPackedSampleModel に基づいた Raster を作成します。
static WritableRaster createPackedRaster(DataBuffer dataBuffer, int w, int h, int bitsPerPixel, Point location)
          指定された DataBuffer、幅、高さ、および 1 ピクセル当たりのビット数を持つ、MultiPixelPackedSampleModel に基づいた Raster を作成します。
static WritableRaster createPackedRaster(int dataType, int w, int h, int[] bandMasks, Point location)
          指定されたデータタイプ、幅、高さ、およびバンドマスクを持つ、SinglePixelPackedSampleModel に基づいた Raster を作成します。
static WritableRaster createPackedRaster(int dataType, int w, int h, int bands, int bitsPerBand, Point location)
          指定されたデータタイプ、幅、高さ、バンド数、および 1 バンド当たりのビット数を持つ、パックされた SampleModel に基づいた Raster を作成します。
static Raster createRaster(SampleModel sm, DataBuffer db, Point location)
          指定された SampleModel と DataBuffer を持つ Raster を作成します。
 Raster createTranslatedChild(int childMinX, int childMinY)
          この Raster と同じサイズ、SampleModel、および DataBuffer を持ち、位置が異なる Raster を作成します。
static WritableRaster createWritableRaster(SampleModel sm, DataBuffer db, Point location)
          指定された SampleModel と DataBuffer を持つ WritableRaster を作成します。
static WritableRaster createWritableRaster(SampleModel sm, Point location)
          指定された SampleModel を持つ WritableRaster を作成します。
 Rectangle getBounds()
          この Raster の境界の Rectangle を返します。
 DataBuffer getDataBuffer()
          この Raster に関連した DataBuffer を返します。
 Object getDataElements(int x, int y, int w, int h, Object outData)
          指定されたピクセル矩形のピクセルデータを transferType 型のプリミティブ配列として返します。
 Object getDataElements(int x, int y, Object outData)
          1 つのピクセルのデータを transferType 型のプリミティブ配列として返します。
 int getHeight()
          Raster の高さをピクセル単位で返します。
 int getMinX()
          Raster の有効な最小の X 座標を返します。
 int getMinY()
          Raster の有効な最小の Y 座標を返します。
 int getNumBands()
          この Raster 内のバンド数 (1 ピクセル当たりのサンプル数) を返します。
 int getNumDataElements()
          getDataElements メソッドと setDataElements メソッドにより 1 つのピクセルを転送するために必要なデータ要素の数を返します。
 Raster getParent()
          この Raster の親 Raster があればそれを返します。
 double[] getPixel(int x, int y, double[] dArray)
          指定されたピクセルのサンプルを double の配列として返します。
 float[] getPixel(int x, int y, float[] fArray)
          指定されたピクセルのサンプルを float の配列として返します。
 int[] getPixel(int x, int y, int[] iArray)
          指定されたピクセルのサンプルを int の配列として返します。
 double[] getPixels(int x, int y, int w, int h, double[] dArray)
          矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている double 配列として返します。
 float[] getPixels(int x, int y, int w, int h, float[] fArray)
          矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている float 配列として返します。
 int[] getPixels(int x, int y, int w, int h, int[] iArray)
          矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている int 配列として返します。
 int getSample(int x, int y, int b)
          (x,y) に位置するピクセルの指定されたバンド内のサンプルを int として返します。
 double getSampleDouble(int x, int y, int b)
          (x,y) に位置するピクセルの指定されたバンド内のサンプルを double として返します。
 float getSampleFloat(int x, int y, int b)
          (x,y) に位置するピクセルの指定されたバンド内のサンプルを float として返します。
 SampleModel getSampleModel()
          イメージデータのレイアウトを記述する SampleModel を返します。
 int getSampleModelTranslateX()
          SampleModel の座標体系から Raster の座標体系への X 変換を返します。
 int getSampleModelTranslateY()
          SampleModel の座標体系から Raster の座標体系への Y 変換を返します。
 double[] getSamples(int x, int y, int w, int h, int b, double[] dArray)
          指定されたピクセル矩形の指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている double 配列として返します。
 float[] getSamples(int x, int y, int w, int h, int b, float[] fArray)
          指定されたピクセル矩形の指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている float 配列として返します。
 int[] getSamples(int x, int y, int w, int h, int b, int[] iArray)
          指定された矩形ピクセルの指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている int 配列として返します。
 int getTransferType()
          getDataElements メソッドと setDataElements メソッドにより複数のピクセルを転送するために必要な transferType を返します。
 int getWidth()
          Raster の幅をピクセル単位で返します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

sampleModel

protected SampleModel sampleModel
この Raster のピクセルが DataBuffer に格納される方法を記述する SampleModel です。

dataBuffer

protected DataBuffer dataBuffer
イメージデータを格納する DataBuffer です。

minX

protected int minX
この Raster の左上隅のピクセルの X 座標です。

minY

protected int minY
この Raster の左上隅のピクセルの Y 座標です。

width

protected int width
この Raster の幅です。

height

protected int height
この Raster の高さです。

sampleModelTranslateX

protected int sampleModelTranslateX
Raster の SampleModel の座標空間から Raster の座標空間への X 変換です。

sampleModelTranslateY

protected int sampleModelTranslateY
Raster の SampleModel の座標空間から Raster の座標空間への Y 変換です。

numBands

protected int numBands
Raster 内のバンド数です。

numDataElements

protected int numDataElements
1 ピクセル当たりの DataBuffer データ要素の数です。

parent

protected Raster parent
この Raster の親、または null です。
コンストラクタの詳細

Raster

protected Raster(SampleModel sampleModel,
                 Point origin)
指定された SampleModel を持つ Raster を構築します。Raster は左上隅が原点で、SampleModel と同じサイズです。Raster を記述するために十分な大きさの DataBuffer が自動的に作成されます。
パラメータ:
sampleModel - レイアウトを指定する SampleModel
origin - 原点を指定した Point

Raster

protected Raster(SampleModel sampleModel,
                 DataBuffer dataBuffer,
                 Point origin)
指定された SampleModel と DataBuffer を持つ Raster を構築します。Raster は左上隅が原点で、SampleModel と同じサイズです。DataBuffer は初期化されず、SampleModel と互換性があります。
パラメータ:
sampleModel - レイアウトを指定する SampleModel
dataBuffer - イメージデータを格納する DataBuffer
origin - 原点を指定する Point

Raster

protected Raster(SampleModel sampleModel,
                 DataBuffer dataBuffer,
                 Rectangle aRegion,
                 Point sampleModelTranslate,
                 Raster parent)
指定された SampleModel、DataBuffer、および親を持つ Raster を構築します。aRegion には、新しい Raster の境界の矩形を指定します。aRegion は、基底 Raster の座標体系に変換されたときに、基底 Raster によって包含されなければなりません (基底 Raster は、Raster の上位オブジェクトであり、親を持たない)。sampleModelTranslate には、新しい Raster の sampleModelTranslateX と sampleModelTranslateY の値を指定します。 このコンストラクタは、通常、ほかのコンストラクタまたは create メソッドによって呼び出されます。直接には使用しないようにしてください。
パラメータ:
sampleModel - レイアウトを指定する SampleModel
dataBuffer - イメージデータを格納する DataBuffer
aRegion - イメージ領域を指定する Rectangle
sampleModelTranslate - SampleModel から Raster 座標への変換を指定する Point
parent - このラスタの親 (存在する場合)
メソッドの詳細

createInterleavedRaster

public static WritableRaster createInterleavedRaster(int dataType,
                                                     int w,
                                                     int h,
                                                     int bands,
                                                     Point location)
指定されたデータタイプ、幅、高さ、およびバンド数を持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。

Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

インタリーブ化された DataBuffer.TYPE_INT Raster はサポートされていません。DataBuffer.TYPE_INT タイプの 1 バンドの Raster を作成するには、Raster.createPackedRaster() を使用します。

現在サポートされている dataType は、TYPE_BYTE および TYPE_USHORT だけです。


createInterleavedRaster

public static WritableRaster createInterleavedRaster(int dataType,
                                                     int w,
                                                     int h,
                                                     int scanlineStride,
                                                     int pixelStride,
                                                     int[] bandOffsets,
                                                     Point location)
指定されたデータタイプ、幅、高さ、走査線ストライド、ピクセルストライド、およびバンドオフセットを持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。バンド数は、bandOffsets.length から推定されます。

Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

インタリーブ化された DataBuffer.TYPE_INT Raster はサポートされていません。DataBuffer.TYPE_INT タイプの 1 バンドの Raster を作成するには、Raster.createPackedRaster() を使用します。

現在サポートされている dataType は、TYPE_BYTE および TYPE_USHORT だけです。

例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合

createBandedRaster

public static WritableRaster createBandedRaster(int dataType,
                                                int w,
                                                int h,
                                                int bands,
                                                Point location)
指定されたデータタイプ、幅、高さ、およびバンド数を持つ、BandedSampleModel に基づいた Raster を作成します。

Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。

例外:
ArrayIndexOutOfBoundsException - bands が 1 未満の場合

createBandedRaster

public static WritableRaster createBandedRaster(int dataType,
                                                int w,
                                                int h,
                                                int scanlineStride,
                                                int[] bankIndices,
                                                int[] bandOffsets,
                                                Point location)
指定されたデータタイプ、幅、高さ、走査線ストライド、バンクインデックス、およびバンドオフセットを持つ、BandedSampleModel に基づいた Raster を作成します。バンド数は、bankIndices.length と bandOffsets.length から推定されます。これら 2 つの長さは同じでなければなりません。

Raster の左上隅は location 引数によって指定されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。

例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合
ArrayIndexOutOfBoundsException - bankIndices または bandOffsetsnull の場合

createPackedRaster

public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int[] bandMasks,
                                                Point location)
指定されたデータタイプ、幅、高さ、およびバンドマスクを持つ、SinglePixelPackedSampleModel に基づいた Raster を作成します。バンド数は bandMasks.length から推定されます。

Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。

例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合

createPackedRaster

public static WritableRaster createPackedRaster(int dataType,
                                                int w,
                                                int h,
                                                int bands,
                                                int bitsPerBand,
                                                Point location)
指定されたデータタイプ、幅、高さ、バンド数、および 1 バンド当たりのビット数を持つ、パックされた SampleModel に基づいた Raster を作成します。バンド数が 1 の場合、SampleModel は MultiPixelPackedSampleModel になります。

バンド数が複数の場合、SampleModel は各バンドが bitsPerBand ビットを持つ SinglePixelPackedSampleModel になります。どちらの場合でも、対応する SampleModel によって義務付けられる dataType と bitsPerBand についての要件を満たさなければなりません。

Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。dataType パラメータは、DataBuffer クラスで定義される、列挙された値の 1 つです。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。

例外:
IllegalArgumentException - bitsPerBandbands の積が、dataType が保持するビット数より大きい場合
IllegalArgumentException - bitsPerBand または bands が 0 以下の場合
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合

createInterleavedRaster

public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
                                                     int w,
                                                     int h,
                                                     int scanlineStride,
                                                     int pixelStride,
                                                     int[] bandOffsets,
                                                     Point location)
指定された DataBuffer、幅、高さ、走査線ストライド、ピクセルストライド、およびバンドオフセットを持つ、PixelInterleavedSampleModel に基づいた Raster を作成します。バンド数は、bandOffsets.length から推定されます。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。

インタリーブ化された DataBuffer.TYPE_INT Raster はサポートされていません。DataBuffer.TYPE_INT タイプの 1 バンドの Raster を作成するには、Raster.createPackedRaster() を使用します。

例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORT のどちらでもない場合
RasterFormatException - dataBuffer に複数のバンクがある場合

createBandedRaster

public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
                                                int w,
                                                int h,
                                                int scanlineStride,
                                                int[] bankIndices,
                                                int[] bandOffsets,
                                                Point location)
指定された DataBuffer、幅、高さ、走査線ストライド、バンクインデックス、およびバンクオフセットを持つ、BandedSampleModel に基づいた Raster を作成します。バンド数は bankIndices.length と bandOffsets.length から推定されます。これら 2 つの長さは同じでなければなりません。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。
例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合

createPackedRaster

public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
                                                int w,
                                                int h,
                                                int scanlineStride,
                                                int[] bandMasks,
                                                Point location)
指定された DataBuffer、幅、高さ、走査線ストライド、およびバンドマスクを持つ、SinglePixelPackedSampleModel に基づいた Raster を作成します。バンド数は bandMasks.length から推定されます。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。
例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合
RasterFormatException - dataBuffer に複数のバンクがある場合

createPackedRaster

public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
                                                int w,
                                                int h,
                                                int bitsPerPixel,
                                                Point location)
指定された DataBuffer、幅、高さ、および 1 ピクセル当たりのビット数を持つ、MultiPixelPackedSampleModel に基づいた Raster を作成します。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。
例外:
IllegalArgumentException - dataType が、サポートされているデータタイプ DataBuffer.TYPE_BYTEDataBuffer.TYPE_USHORTDataBuffer.TYPE_INT のどれでもない場合
RasterFormatException - dataBuffer に複数のバンクがある場合

createRaster

public static Raster createRaster(SampleModel sm,
                                  DataBuffer db,
                                  Point location)
指定された SampleModel と DataBuffer を持つ Raster を作成します。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。
例外:
RasterFormatException - dataBuffer に複数のバンクがあり、sampleModel が PixelInterleavedSampleModel、SinglePixelPackedSampleModel、または MultiPixelPackedSampleModel の場合

createWritableRaster

public static WritableRaster createWritableRaster(SampleModel sm,
                                                  Point location)
指定された SampleModel を持つ WritableRaster を作成します。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。


createWritableRaster

public static WritableRaster createWritableRaster(SampleModel sm,
                                                  DataBuffer db,
                                                  Point location)
指定された SampleModel と DataBuffer を持つ WritableRaster を作成します。Raster の左上隅は location 引数によって指定されます。location が null の場合は、(0, 0) が使用されます。

現在サポートされている dataType は、TYPE_BYTE、TYPE_USHORT および TYPE_INT だけです。

例外:
RasterFormatException - dataBuffer に複数のバンクがあり、sampleModel が PixelInterleavedSampleModel、SinglePixelPackedSampleModel、または MultiPixelPackedSampleModel の場合

getParent

public Raster getParent()
この Raster の親 Raster があればそれを返します。親がない場合は、null を返します。

getSampleModelTranslateX

public final int getSampleModelTranslateX()
SampleModel の座標体系から Raster の座標体系への X 変換を返します。ピクセルの X 座標を Raster の座標体系から SampleModel の座標体系に変換するには、この値を減算する必要があります。

getSampleModelTranslateY

public final int getSampleModelTranslateY()
SampleModel の座標体系から Raster の座標体系への Y 変換を返します。ピクセルの Y 座標を Raster の座標体系から SampleModel の座標体系に変換するには、この値を減算する必要があります。

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster()
この Raster と同じ SampleModel と初期化された新しい DataBuffer を持つ、この Raster と同じサイズで互換性のある WritableRaster を作成します。

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster(int w,
                                                     int h)
指定されたサイズ、新しい SampleModel、初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。
例外:
RasterFormatException - 幅または高さがゼロ以下の場合

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster(Rectangle rect)
rect によって指定される位置 (minX, minY) とサイズ (width, height)、新しい SampleModel、および初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster(int x,
                                                     int y,
                                                     int w,
                                                     int h)
指定された位置 (minX, minY) とサイズ (width, height)、新しい SampleModel、および初期化された新しい DataBuffer を持つ、互換性のある WritableRaster を作成します。

createTranslatedChild

public Raster createTranslatedChild(int childMinX,
                                    int childMinY)
この Raster と同じサイズ、SampleModel、および DataBuffer を持ち、位置が異なる Raster を作成します。新しい Raster は、getParent() メソッドによりアクセス可能な、現在の Raster への参照を持ちます。
パラメータ:
childMinX - 新しい Raster の左上隅の X 座標
childMinY - 新しい Raster の左上隅の Y 座標

createChild

public Raster createChild(int parentX,
                          int parentY,
                          int width,
                          int height,
                          int childMinX,
                          int childMinY,
                          int[] bandList)
この Raster の DataBuffer のすべてまたは一部を共有する新しい Raster を返します。新しい Raster は、getParent() メソッドによりアクセス可能な、現在の Raster への参照を持ちます。

parentX、parentY、width、height の各パラメータによってこの Raster の座標空間に形成される Rectangle が、共有されるピクセル領域を示します。この Rectangle が現在の Raster の境界内にない場合は、エラーがスローされます。

新しい Raster はさらに、同じ平面上で現在の Raster が使用する座標体系とは異なる座標体系に変換できます。childMinX パラメータと childMinY パラメータにより、返された Raster の左上隅にあるピクセルの新しい座標 (x, y) が指定されます。新しい Raster 内の座標 (childMinX, childMinY) は、現在の Raster 内の座標 (parentX, parentY) と同じピクセルにマップされます。

bandList パラメータを使用して、新しい Raster が現在の Raster のバンドのサブセットだけを、場合によっては順序付をし直して、格納するように定義できます。bandList が null の場合は、現在の Raster のすべてのバンドが現在と同じ順序で格納されます。

現在の Raster の部分領域を保持するが、座標体系とバンドは現在の Raster と共有する新しい Raster を作成するには、childMinX を parentX と同じに、childMinY を parentY と同じに、bandList を null にそれぞれ指定して、このメソッドを呼び出します。

パラメータ:
parentX - この Raster の座標で左上隅の X 座標
parentY - この Raster の座標で左上隅の Y 座標
width - (parentX, parentY) から始まる領域の幅
height - (parentX, parentY) から始まる領域の高さ
childMinX - 返される Raster の左上隅の X 座標
childMinY - 返される Raster の左上隅の Y 座標
bandList - バンドインデックスの配列。すべてのバンドを使用する場合は null
例外:
RasterFormatException - 指定された部分領域がラスタの境界の外側にある場合

getBounds

public Rectangle getBounds()
この Raster の境界の Rectangle を返します。この関数は、getMinX/MinY/Width/Height と同じ情報を返します。

getMinX

public final int getMinX()
Raster の有効な最小の X 座標を返します。

getMinY

public final int getMinY()
Raster の有効な最小の Y 座標を返します。

getWidth

public final int getWidth()
Raster の幅をピクセル単位で返します。

getHeight

public final int getHeight()
Raster の高さをピクセル単位で返します。

getNumBands

public final int getNumBands()
この Raster 内のバンド数 (1 ピクセル当たりのサンプル数) を返します。

getNumDataElements

public final int getNumDataElements()
getDataElements メソッドと setDataElements メソッドにより 1 つのピクセルを転送するために必要なデータ要素の数を返します。これらのメソッドでは、ピクセルがパックされた形式で転送される場合とアンパックされた形式で転送される場合があり、これは、基本となる SampleModel の実装によって決まります。これらのメソッドを使うと、ピクセルは getTransferType() によって指定されるプリミティブ型の getNumDataElements() 要素の配列として転送されます。transferType は、DataBuffer のストレージデータタイプと同じでも、異なっていてもかまいません。

getTransferType

public final int getTransferType()
getDataElements メソッドと setDataElements メソッドにより複数のピクセルを転送するために必要な transferType を返します。これらのメソッドでは、ピクセルがパックされた形式で転送される場合とアンパックされた形式で転送される場合があり、これは、基本となる SampleModel の実装によって決まります。これらのメソッドを使うと、ピクセルは getTransferType() によって指定されるプリミティブ型の getNumDataElements() 要素の配列として転送されます。transferType は、DataBuffer で定義されているタイプの 1 つになります。

getDataBuffer

public DataBuffer getDataBuffer()
この Raster に関連した DataBuffer を返します。

getSampleModel

public SampleModel getSampleModel()
イメージデータのレイアウトを記述する SampleModel を返します。

getDataElements

public Object getDataElements(int x,
                              int y,
                              Object outData)
1 つのピクセルのデータを transferType 型のプリミティブ配列として返します。Java 2D(tm) API によってサポートされているイメージデータの場合は、DataBuffer.TYPE_BYTE、DataBuffer.TYPE_USHORT、DataBuffer.TYPE_INT のどれかになります。データはパックされた形式で返されることもあり、その場合、データ転送の効率が上がります。パラメータでの明示的な境界のチェックはありません。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。入力オブジェクトが null でなく、transferType 配列以外を参照している場合は、ClassCastException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
outData - getTransferType() によって定義されるタイプと getNumDataElements() によって定義される長さを持つ配列へのオブジェクト参照。null の場合は、適切なタイプとサイズの配列が割り当てられる
戻り値:
要求されたピクセルデータを持つ、getTransferType() で定義されるタイプの配列へのオブジェクト参照
関連項目:
SampleModel.getDataElements(int, int, Object, DataBuffer)

getDataElements

public Object getDataElements(int x,
                              int y,
                              int w,
                              int h,
                              Object outData)
指定されたピクセル矩形のピクセルデータを transferType 型のプリミティブ配列として返します。Java 2D API によってサポートされているイメージデータの場合は、DataBuffer.TYPE_BYTE、DataBuffer.TYPE_USHORT、DataBuffer.TYPE_INT のどれかになります。データはパックされた形式で返されることもあり、その場合、データ転送の効率が上がります。パラメータでの明示的な境界のチェックはありません。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。入力オブジェクトが null でなく、transferType 配列以外を参照している場合は、ClassCastException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
width - ピクセル矩形の幅
height - ピクセル矩形の高さ
outData - getTransferType() によって定義されるタイプと w*h*getNumDataElements() によって定義される長さを持つ配列へのオブジェクト参照。null の場合は、適切なタイプとサイズの配列が割り当てられる
戻り値:
要求されたピクセルデータを持つ、getTransferType() で定義されるタイプの配列へのオブジェクト参照
関連項目:
SampleModel.getDataElements(int, int, int, int, Object, DataBuffer)

getPixel

public int[] getPixel(int x,
                      int y,
                      int[] iArray)
指定されたピクセルのサンプルを int の配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
iArray - 必要に応じて事前に割り当てられた int 配列

getPixel

public float[] getPixel(int x,
                        int y,
                        float[] fArray)
指定されたピクセルのサンプルを float の配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
fArray - 必要に応じて事前に割り当てられた float 配列

getPixel

public double[] getPixel(int x,
                         int y,
                         double[] dArray)
指定されたピクセルのサンプルを double の配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
dArray - 必要に応じて事前に割り当てられた double 配列

getPixels

public int[] getPixels(int x,
                       int y,
                       int w,
                       int h,
                       int[] iArray)
矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている int 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
iArray - 必要に応じて事前に割り当てられた int 配列

getPixels

public float[] getPixels(int x,
                         int y,
                         int w,
                         int h,
                         float[] fArray)
矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている float 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
fArray - 必要に応じて事前に割り当てられた float 配列

getPixels

public double[] getPixels(int x,
                          int y,
                          int w,
                          int h,
                          double[] dArray)
矩形のピクセルのサンプルすべてを、配列要素ごとに 1 つのサンプルが格納されている double 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
dArray - 必要に応じて事前に割り当てられた double 配列

getSample

public int getSample(int x,
                     int y,
                     int b)
(x,y) に位置するピクセルの指定されたバンド内のサンプルを int として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
b - 返されるバンド

getSampleFloat

public float getSampleFloat(int x,
                            int y,
                            int b)
(x,y) に位置するピクセルの指定されたバンド内のサンプルを float として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
b - 返されるバンド

getSampleDouble

public double getSampleDouble(int x,
                              int y,
                              int b)
(x,y) に位置するピクセルの指定されたバンド内のサンプルを double として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - ピクセル位置の X 座標
y - ピクセル位置の Y 座標
b - 返されるバンド

getSamples

public int[] getSamples(int x,
                        int y,
                        int w,
                        int h,
                        int b,
                        int[] iArray)
指定された矩形ピクセルの指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている int 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
b - 返されるバンド
iArray - 必要に応じて事前に割り当てられた int 配列

getSamples

public float[] getSamples(int x,
                          int y,
                          int w,
                          int h,
                          int b,
                          float[] fArray)
指定されたピクセル矩形の指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている float 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
b - 返されるバンド
fArray - 必要に応じて事前に割り当てられた float 配列

getSamples

public double[] getSamples(int x,
                           int y,
                           int w,
                           int h,
                           int b,
                           double[] dArray)
指定されたピクセル矩形の指定されたバンドのサンプルを、配列要素ごとに 1 つのサンプルが格納されている double 配列として返します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException がスローされます。
パラメータ:
x - 左上のピクセル位置の X 座標
y - 左上のピクセル位置の Y 座標
w - ピクセル矩形の幅
h - ピクセル矩形の高さ
b - 返されるバンド
dArray - 必要に応じて事前に割り当てられた double 配列

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.