final DataBufferInt db = (DataBufferInt)r.getDataBuffer();
final int[] pixels = db.getBankData()[0];
final SinglePixelPackedSampleModel sppsm;
sppsm = (SinglePixelPackedSampleModel)r.getSampleModel();
final int scanStride = sppsm.getScanlineStride();
final int scanStridePP = scanStride + 1;
final int scanStrideMM = scanStride - 1;
int a = 0;
int i=0, j=0;
double prpc=0, prcc=0, prnc=0;
double crpc=0, crcc=0, crnc=0;
double nrpc=0, nrcc=0, nrnc=0;
double invNorm;
final double quarterSurfaceScaleX = surfaceScaleX / 4f;
final double quarterSurfaceScaleY = surfaceScaleY / 4f;
final double halfSurfaceScaleX = surfaceScaleX / 2f;
final double halfSurfaceScaleY = surfaceScaleY /2;
final double thirdSurfaceScaleX = surfaceScaleX / 3f;
final double thirdSurfaceScaleY = surfaceScaleY / 3f;
final double twoThirdSurfaceScaleX = surfaceScaleX * 2 / 3f;
final double twoThirdSurfaceScaleY = surfaceScaleY * 2 / 3f;
final double pixelScale = 1.0/255;
if(w <= 0)
return N;
// Process pixels on the border
if(h <= 0)
return N;
final int xEnd = Math.min(srcRect.x+srcRect.width -1, x+w);
final int yEnd = Math.min(srcRect.y+srcRect.height-1, y+h);
final int offset =
(db.getOffset() +
sppsm.getOffset(srcRect.x -r.getSampleModelTranslateX(),
srcRect.y -r.getSampleModelTranslateY()));
int yloc=y;
if (yloc < srcRect.y) {
yloc = srcRect.y;