{
// extract the raw image from the sample
final RawEncodedImage rawIm = RawEncodedImage.fromQTHandle(mediaSample.data);
dSeq.decompressFrameS(rawIm, 0);
// the raw image is rendered into qdGraphics, being decompressed
// as it goes
rawIm.disposeQTObject();
/*
* Make the data buffer of the img BufferedImage accessible via a pixel
* array (imgPixelData[]).
*/
final WritableRaster tile = img.getWritableTile(0, 0);
int[] imgPixelData = ((DataBufferInt) tile.getDataBuffer()).getData();
// pull a raw image from qdGraphics (this one will be decompressed)
final RawEncodedImage rawIm2 = qdGraphics.getPixMap().getPixelData();
/*
* Transfer the raw image into the img BufferedImage via a
* imgPixelData[] pixel array. This is simple if the size of the raw
* image matches the destination pixel array (see the else branch),
* otherwise, only a subset is copied over (see the if branch).
*/
if (rowInts != width)
{
/*
* Copy raw image to pixData[], then a subset of pixData[] into
* imgPixelData[].
*/
rawIm2.copyToArray(0, pixData, 0, pixData.length);
int pixIndex = 0, destPixIndex = 0;
for (int row = 0; row < height; row++)
{
int cLimit = pixIndex + width;
for (int cIndex = pixIndex; cIndex < cLimit; cIndex++)
imgPixelData[destPixIndex++] = pixData[cIndex];
pixIndex += rowInts;
}
} else
{ // copy raw image to imgPixelData[] in one step
rawIm2.copyToArray(0, imgPixelData, 0, width * height);
}
img.releaseWritableTile(0, 0); // release Raster access to image