/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* An ImageFilter class for scaling images using a simple area averaging
* algorithm that produces smoother results than the nearest neighbor
* algorithm.
* <p>This class extends the basic ImageFilter Class to scale an existing
* image and provide a source for a new image containing the resampled
* image. The pixels in the source image are blended to produce pixels
* for an image of the specified size. The blending process is analogous
* to scaling up the source image to a multiple of the destination size
* using pixel replication and then scaling it back down to the destination
* size by simply averaging all the pixels in the supersized image that
* fall within a given pixel of the destination image. If the data from
* the source is not delivered in TopDownLeftRight order then the filter
* will back off to a simple pixel replication behavior and utilize the
* requestTopDownLeftRightResend() method to refilter the pixels in a
* better way at the end.
* <p>It is meant to be used in conjunction with a FilteredImageSource
* object to produce scaled versions of existing images. Due to
* implementation dependencies, there may be differences in pixel values
* of an image filtered on different platforms.
*
* @see FilteredImageSource
* @see ReplicateScaleFilter
* @see ImageFilter
*
* @author Jim Graham
*/
private boolean passthrough;
private int savedy;
private int savedyrem;
/**
* Constructs an AreaAveragingScaleFilter that scales the pixels from
* its source Image as specified by the width and height parameters.
* @param width the target width to scale the image
* @param height the target height to scale the image
*/
}
/**
* Detect if the data is being delivered with the necessary hints
* to allow the averaging algorithm to do its work.
* <p>
* Note: This method is intended to be called by the
* <code>ImageProducer</code> of the <code>Image</code> whose
* pixels are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
* @see ImageConsumer#setHints
*/
}
private void makeAccumBuffers() {
}
private int[] calcRow() {
}
for (int x = 0; x < destWidth; x++) {
if (a <= 0) {
a = 0;
} else if (a >= 255) {
a = 255;
} else {
// un-premultiply the components (by modifying mult here, we
// are effectively doing the divide by mult and divide by
// alpha in the same step)
}
if (r < 0) {r = 0;} else if (r > 255) {r = 255;}
if (g < 0) {g = 0;} else if (g > 255) {g = 255;}
if (b < 0) {b = 0;} else if (b > 255) {b = 255;}
}
return outpix;
}
private void accumPixels(int x, int y, int w, int h,
int scansize) {
}
int sy = y;
int syrem = destHeight;
if (sy == 0) {
dy = 0;
dyrem = 0;
} else {
}
while (sy < y + h) {
int amty;
if (dyrem == 0) {
for (int i = 0; i < destWidth; i++) {
}
}
} else {
}
int sx = 0;
int dx = 0;
int sxrem = 0;
float a = 0f, r = 0f, g = 0f, b = 0f;
while (sx < w) {
if (sxrem == 0) {
int rgb;
if (pixels instanceof byte[]) {
} else {
}
// getRGB() always returns non-premultiplied components
a = rgb >>> 24;
b = rgb & 0xff;
// premultiply the components if necessary
if (a != 255.0f) {
float ascale = a / 255.0f;
r *= ascale;
g *= ascale;
b *= ascale;
}
}
int amtx;
} else {
}
sx++;
}
dx++;
}
}
do {
dy++;
} else {
}
if (syrem == 0) {
syrem = destHeight;
sy++;
}
}
}
/**
* Combine the components for the delivered byte pixels into the
* accumulation arrays and send on any averaged data for rows of
* pixels that are complete. If the correct hints were not
* specified in the setHints call then relay the work to our
* superclass which is capable of scaling pixels regardless of
* the delivery hints.
* <p>
* Note: This method is intended to be called by the
* <code>ImageProducer</code> of the <code>Image</code>
* whose pixels are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
* @see ReplicateScaleFilter
*/
public void setPixels(int x, int y, int w, int h,
int scansize) {
if (passthrough) {
} else {
}
}
/**
* Combine the components for the delivered int pixels into the
* accumulation arrays and send on any averaged data for rows of
* pixels that are complete. If the correct hints were not
* specified in the setHints call then relay the work to our
* superclass which is capable of scaling pixels regardless of
* the delivery hints.
* <p>
* Note: This method is intended to be called by the
* <code>ImageProducer</code> of the <code>Image</code>
* whose pixels are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
* @see ReplicateScaleFilter
*/
public void setPixels(int x, int y, int w, int h,
int scansize) {
if (passthrough) {
} else {
}
}
}