Java 类java.awt.image.ReplicateScaleFilter 实例源码
项目:Visualizer
文件:Visualizer.java
@Override
public void paint(Graphics g){
super.paint(g);
// Have the extending class draw on an image so that it can be resized as needed
Image bufferImage = createImage(DRAW_WIDTH, DRAW_HEIGHT);
// Give control to visualization to draw on buffer
paintVisualization((Graphics2D)bufferImage.getGraphics());
int width = getWidth();
int height = getHeight();
// Scale and resize the image
ReplicateScaleFilter scale = new ReplicateScaleFilter(width, height);
FilteredImageSource fis = new FilteredImageSource(bufferImage.getSource(), scale);
Image croppedImage = createImage(fis);
g.drawImage(croppedImage, 0, 0, null);
Toolkit.getDefaultToolkit().sync();
}
项目:javify
文件:AbstractGraphics2D.java
/**
* Scales an image to the specified width and height. This should also
* be used to implement
* {@link Toolkit#prepareImage(Image, int, int, ImageObserver)}.
* This uses {@link Toolkit#createImage(ImageProducer)} to create the actual
* image.
*
* @param image the image to prepare
* @param w the width
* @param h the height
*
* @return the scaled image
*/
public static Image prepareImage(Image image, int w, int h)
{
// Try to find cached scaled image.
HashMap<Dimension,Image> scaledTable = imageCache.get(image);
Dimension size = new Dimension(w, h);
Image scaled = null;
if (scaledTable != null)
{
scaled = scaledTable.get(size);
}
if (scaled == null)
{
// No cached scaled image. Start scaling image now.
ImageProducer source = image.getSource();
ReplicateScaleFilter scaler = new ReplicateScaleFilter(w, h);
FilteredImageSource filteredSource =
new FilteredImageSource(source, scaler);
// Ideally, this should asynchronously scale the image.
Image scaledImage =
Toolkit.getDefaultToolkit().createImage(filteredSource);
scaled = scaledImage;
// Put scaled image in cache.
if (scaledTable == null)
{
scaledTable = new HashMap<Dimension,Image>();
imageCache.put(image, scaledTable);
}
scaledTable.put(size, scaledImage);
}
return scaled;
}
项目:jvm-stm
文件:AbstractGraphics2D.java
/**
* Scales an image to the specified width and height. This should also
* be used to implement
* {@link Toolkit#prepareImage(Image, int, int, ImageObserver)}.
* This uses {@link Toolkit#createImage(ImageProducer)} to create the actual
* image.
*
* @param image the image to prepare
* @param w the width
* @param h the height
*
* @return the scaled image
*/
public static Image prepareImage(Image image, int w, int h)
{
// Try to find cached scaled image.
HashMap<Dimension,Image> scaledTable = imageCache.get(image);
Dimension size = new Dimension(w, h);
Image scaled = null;
if (scaledTable != null)
{
scaled = scaledTable.get(size);
}
if (scaled == null)
{
// No cached scaled image. Start scaling image now.
ImageProducer source = image.getSource();
ReplicateScaleFilter scaler = new ReplicateScaleFilter(w, h);
FilteredImageSource filteredSource =
new FilteredImageSource(source, scaler);
// Ideally, this should asynchronously scale the image.
Image scaledImage =
Toolkit.getDefaultToolkit().createImage(filteredSource);
scaled = scaledImage;
// Put scaled image in cache.
if (scaledTable == null)
{
scaledTable = new HashMap<Dimension,Image>();
imageCache.put(image, scaledTable);
}
scaledTable.put(size, scaledImage);
}
return scaled;
}
项目:aTunes
文件:ImageUtils.java
public static BufferedImage scaleImage(Image sourceImage, int width, int height)
{
if (sourceImage == null)
return null;
ImageFilter filter = new ReplicateScaleFilter(width,height);
ImageProducer producer = new FilteredImageSource(sourceImage.getSource(),filter);
Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);
return toBufferedImage(resizedImage);
}
项目:JamVM-PH
文件:AbstractGraphics2D.java
/**
* Scales an image to the specified width and height. This should also
* be used to implement
* {@link Toolkit#prepareImage(Image, int, int, ImageObserver)}.
* This uses {@link Toolkit#createImage(ImageProducer)} to create the actual
* image.
*
* @param image the image to prepare
* @param w the width
* @param h the height
*
* @return the scaled image
*/
public static Image prepareImage(Image image, int w, int h)
{
// Try to find cached scaled image.
HashMap<Dimension,Image> scaledTable = imageCache.get(image);
Dimension size = new Dimension(w, h);
Image scaled = null;
if (scaledTable != null)
{
scaled = scaledTable.get(size);
}
if (scaled == null)
{
// No cached scaled image. Start scaling image now.
ImageProducer source = image.getSource();
ReplicateScaleFilter scaler = new ReplicateScaleFilter(w, h);
FilteredImageSource filteredSource =
new FilteredImageSource(source, scaler);
// Ideally, this should asynchronously scale the image.
Image scaledImage =
Toolkit.getDefaultToolkit().createImage(filteredSource);
scaled = scaledImage;
// Put scaled image in cache.
if (scaledTable == null)
{
scaledTable = new HashMap<Dimension,Image>();
imageCache.put(image, scaledTable);
}
scaledTable.put(size, scaledImage);
}
return scaled;
}
项目:classpath
文件:AbstractGraphics2D.java
/**
* Scales an image to the specified width and height. This should also
* be used to implement
* {@link Toolkit#prepareImage(Image, int, int, ImageObserver)}.
* This uses {@link Toolkit#createImage(ImageProducer)} to create the actual
* image.
*
* @param image the image to prepare
* @param w the width
* @param h the height
*
* @return the scaled image
*/
public static Image prepareImage(Image image, int w, int h)
{
// Try to find cached scaled image.
HashMap<Dimension,Image> scaledTable = imageCache.get(image);
Dimension size = new Dimension(w, h);
Image scaled = null;
if (scaledTable != null)
{
scaled = scaledTable.get(size);
}
if (scaled == null)
{
// No cached scaled image. Start scaling image now.
ImageProducer source = image.getSource();
ReplicateScaleFilter scaler = new ReplicateScaleFilter(w, h);
FilteredImageSource filteredSource =
new FilteredImageSource(source, scaler);
// Ideally, this should asynchronously scale the image.
Image scaledImage =
Toolkit.getDefaultToolkit().createImage(filteredSource);
scaled = scaledImage;
// Put scaled image in cache.
if (scaledTable == null)
{
scaledTable = new HashMap<Dimension,Image>();
imageCache.put(image, scaledTable);
}
scaledTable.put(size, scaledImage);
}
return scaled;
}
项目:Deskera-HRMS
文件:FileUploadHandler.java
private BufferedImage scaleImage(Image sourceImage, int width, int height, int typeRGB) {
ImageFilter filter = new ReplicateScaleFilter(width, height);
ImageProducer producer = new FilteredImageSource(sourceImage
.getSource(), filter);
Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);
return this.toBufferedImage(resizedImage, typeRGB);
}
项目:jumbertoTeia2600
文件:SpectrogramPanel.java
/** Zoom the image, preparing for new display. */
protected void zoomSet(float zoom) {
this.zoom = zoom;
if (spectrogram != null) {
int width = spectrogram.getWidth();
int height = spectrogram.getHeight();
ImageFilter scaleFilter =
new ReplicateScaleFilter((int) (zoom * width), height);
scaledSpectrogram =
createImage(new FilteredImageSource(spectrogram.getSource(),
scaleFilter));
repaint();
}
}
项目:openjdk-jdk10
文件:HeadlessReplicateScaleFilter.java
public static void main(String args[]) {
new ReplicateScaleFilter(100, 100).clone();
}
项目:openjdk9
文件:HeadlessReplicateScaleFilter.java
public static void main(String args[]) {
new ReplicateScaleFilter(100, 100).clone();
}
项目:Deskera-HRMS
文件:Snap.java
private static BufferedImage scaleCompanyImage(Image sourceImage, int width, int height) {
ImageFilter filter = new ReplicateScaleFilter(width, height);
ImageProducer producer = new FilteredImageSource(sourceImage.getSource(), filter);
Image rImage = Toolkit.getDefaultToolkit().createImage(producer);
return toBufferedCompanyImage(rImage);
}