Hi,
can anyone please say me the difference between
BufferedImage.getData() and WritableRaster.getDataBuffer()?
In java Api,its mentioned like BufferedImage.getData() ll return one large tile.
wat does it actually mean?please anyone respond to this mail ASAP..
Thanks in Advance.
Thanks & Regards,
Hamsa
It helps if you know the basic structure of the classes involved.
- BufferedImage has a ColorModel and a WritableRaster.
- ColorModel has a ColorSpace.
- WritableRaster has a SampleModel and a DataBuffer.
What are the jobs of this classes?
- BufferedImage is the top level image class.
- ColorModel knows how to translate between pixel data and color components.
- ColorSpace describes the collection of possible colors.
- WritableRaster represents a rectangular area of pixel data.
- SampleModel knows how to extract pixels samples from a DataBuffer.
- DataBuffer is a thin wrapper around one or more arrays (usually one) of pixel data.
Now let's look at the methods you mentioned:
- //BufferedImage:
-
Raster getData()
-
WritableRaster getRaster()
-
-
//WriteableRaster/Raster:
-
DataBuffer getDataBuffer()
Methods getRaster() and getDataBuffer() return the basic components of the respective
objects -- there is no copying involved. Method getData(), as the API makes clear:
The Raster returned is a copy of the image data is not updated if the image is changed.
Now the most important questions:
- Why do you ask?
- What are you trying to do?
- What is your goal?
- What about doing this with other sections of the API?