本文整理汇总了Java中java.awt.image.ReplicateScaleFilter类的典型用法代码示例。如果您正苦于以下问题:Java ReplicateScaleFilter类的具体用法?Java ReplicateScaleFilter怎么用?Java ReplicateScaleFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReplicateScaleFilter类属于java.awt.image包,在下文中一共展示了ReplicateScaleFilter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
@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();
}
示例2: prepareImage
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
/**
* 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;
}
示例3: scaleImage
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
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);
}
示例4: scaleImage
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
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);
}
示例5: zoomSet
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
/** 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();
}
}
示例6: main
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
public static void main(String args[]) {
new ReplicateScaleFilter(100, 100).clone();
}
示例7: scaleCompanyImage
import java.awt.image.ReplicateScaleFilter; //导入依赖的package包/类
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);
}