本文整理汇总了Java中java.awt.ImageCapabilities类的典型用法代码示例。如果您正苦于以下问题:Java ImageCapabilities类的具体用法?Java ImageCapabilities怎么用?Java ImageCapabilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageCapabilities类属于java.awt包,在下文中一共展示了ImageCapabilities类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSurfaceManager
import java.awt.ImageCapabilities; //导入依赖的package包/类
protected VolatileSurfaceManager createSurfaceManager(Object context,
ImageCapabilities caps)
{
/**
* Platform-specific SurfaceManagerFactories will return a
* manager suited to acceleration on each platform. But if
* the user is asking for a VolatileImage from a BufferedImageGC,
* then we need to return the appropriate unaccelerated manager.
* Note: this could change in the future; if some platform would
* like to accelerate BIGC volatile images, then this special-casing
* of the BIGC graphicsConfig should live in platform-specific
* code instead.
* We do the same for a Printer Device, and if user requested an
* unaccelerated VolatileImage by passing the capabilities object.
*/
if (graphicsConfig instanceof BufferedImageGraphicsConfig ||
graphicsConfig instanceof sun.print.PrinterGraphicsConfig ||
(caps != null && !caps.isAccelerated()))
{
return new BufImgVolatileSurfaceManager(this, context);
}
SurfaceManagerFactory smf = SurfaceManagerFactory.getInstance();
return smf.createVolatileManager(this, context);
}
示例2: render
import java.awt.ImageCapabilities; //导入依赖的package包/类
public void render() {
ImageCapabilities imgBackBufCap = new ImageCapabilities(true);
ImageCapabilities imgFrontBufCap = new ImageCapabilities(true);
BufferCapabilities bufCap =
new BufferCapabilities(imgFrontBufCap,
imgBackBufCap, BufferCapabilities.FlipContents.COPIED);
try {
createBufferStrategy(2, bufCap);
} catch (AWTException ex) {
createBufferStrategy(2);
}
BufferStrategy bs = getBufferStrategy();
do {
Graphics g = bs.getDrawGraphics();
g.setColor(Color.green);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.red);
g.drawString("Rendering test", 20, 20);
g.drawImage(bi, 50, 50, null);
g.dispose();
bs.show();
} while (bs.contentsLost()||bs.contentsRestored());
}
示例3: createScreen
import java.awt.ImageCapabilities; //导入依赖的package包/类
/**
* 创建初始的Graphics
*/
public void createScreen() {
int width = getWidth();
int height = getHeight();
try {
hardwareImage = createVolatileImage(width, height, new ImageCapabilities(true));
} catch (Exception e) {
hardwareImage = null;
int pixelSize = width * height;
int[] pixels = new int[pixelSize];
this.awtImage = GraphicsUtils.newAwtRGBImage(pixels, width, height, pixelSize);
}
if (hardwareImage == null) {
this.isSupportHardware = false;
this.gl = new LGraphics(awtImage);
} else {
this.isSupportHardware = true;
this.gl = new LGraphics(hardwareImage);
}
LSystem.screenRect = new RectBox(0, 0, width, height);
}
示例4: showGraphicsConfiguration
import java.awt.ImageCapabilities; //导入依赖的package包/类
private void showGraphicsConfiguration(final GraphicsConfiguration gc) {
System.out.println(" pixel size: " + gc.getColorModel().getPixelSize());
System.out.println(" bounds: " + gc.getBounds().toString());
final GraphicsDevice gd = gc.getDevice();
System.out.println(" isFullScreenSupported: " + gd.isFullScreenSupported());
System.out.println(" isDisplayChangeSupported: " + gd.isDisplayChangeSupported());
System.out.println(" memory: " + gd.getAvailableAcceleratedMemory()
+ (gd.getAvailableAcceleratedMemory() < 0 ? " (unlimited)" : ""));
final DisplayMode dm = gd.getDisplayMode();
System.out.println(" disp size: " + dm.getWidth() + "x" + dm.getHeight());
System.out.println(" disp depth: " + dm.getBitDepth());
System.out.println(" disp refresh: " + dm.getRefreshRate());
final BufferCapabilities bc = gc.getBufferCapabilities();
System.out.println(" full screen required: " + bc.isFullScreenRequired());
System.out.println(" multi buffer available: " + bc.isMultiBufferAvailable());
System.out.println(" page flipping: " + bc.isPageFlipping());
final ImageCapabilities ic = gc.getImageCapabilities();
System.out.println(" is accel: " + ic.isAccelerated());
}
示例5: printDisplayInfo
import java.awt.ImageCapabilities; //导入依赖的package包/类
public static void printDisplayInfo() {
int g = 0;
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
out.println("graphics device #"+(++g)+": "+gd.getIDstring()+" type "+gd.getType());
out.println("\tavailable accelerated memory " + gd.getAvailableAcceleratedMemory());
int c = 0;
for (GraphicsConfiguration gc : gd.getConfigurations()) {
out.println("\tgraphics configuration #"+(++c)+":");
out.println("\t\twidth "+gc.getBounds().getWidth()+" height "+gc.getBounds().getHeight());
out.println("\t\tfull screen "+gc.getBufferCapabilities().isFullScreenRequired());
ImageCapabilities ic = gc.getImageCapabilities();
out.println("\t\tis accelerated "+ic.isAccelerated());
}
DisplayMode dm = gd.getDisplayMode();
out.println("\tdisplay mode bit width "+dm.getWidth()+" height "+dm.getHeight()+" bit depth "+dm.getBitDepth()+" refresh rate "+dm.getRefreshRate());
int m = 0;
for (DisplayMode d : gd.getDisplayModes())
out.println("\talt display mode #"+(++m)+" bit width "+d.getWidth()+" height "+d.getHeight()+" bit depth "+d.getBitDepth()+" refresh rate "+d.getRefreshRate());
}
}
示例6: ExtendedBufferCapabilities
import java.awt.ImageCapabilities; //导入依赖的package包/类
/**
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
* from the passed caps, and VSYNC_DEFAULT v-sync mode.
*/
public ExtendedBufferCapabilities(ImageCapabilities front,
ImageCapabilities back, FlipContents flip)
{
super(front, back, flip);
this.vsync = VSyncType.VSYNC_DEFAULT;
}
示例7: getCapabilities
import java.awt.ImageCapabilities; //导入依赖的package包/类
@Override
public ImageCapabilities getCapabilities(GraphicsConfiguration gc) {
if (isConfigValid(gc)) {
return isAccelerationEnabled() ?
new AcceleratedImageCapabilities() :
new ImageCapabilities(false);
}
return super.getCapabilities(gc);
}
示例8: SunVolatileImage
import java.awt.ImageCapabilities; //导入依赖的package包/类
protected SunVolatileImage(Component comp,
GraphicsConfiguration graphicsConfig,
int width, int height, Object context,
int transparency, ImageCapabilities caps,
int accType)
{
this.comp = comp;
this.graphicsConfig = graphicsConfig;
this.width = width;
this.height = height;
this.forcedAccelSurfaceType = accType;
if (!(transparency == Transparency.OPAQUE ||
transparency == Transparency.BITMASK ||
transparency == Transparency.TRANSLUCENT))
{
throw new IllegalArgumentException("Unknown transparency type:" +
transparency);
}
this.transparency = transparency;
this.volSurfaceManager = createSurfaceManager(context, caps);
SurfaceManager.setManager(this, volSurfaceManager);
// post-construction initialization of the surface manager
volSurfaceManager.initialize();
// clear the background
volSurfaceManager.initContents();
}
示例9: getCapabilities
import java.awt.ImageCapabilities; //导入依赖的package包/类
/**
* Need to override the default behavior because Pixmaps-based
* images are accelerated but not volatile.
*/
@Override
public ImageCapabilities getCapabilities(GraphicsConfiguration gc) {
if (isConfigValid(gc) && isAccelerationEnabled()) {
return new ImageCapabilities(true);
}
return new ImageCapabilities(false);
}
示例10: getCapabilities
import java.awt.ImageCapabilities; //导入依赖的package包/类
/**
* Need to override the default behavior because Pixmaps-based
* images are accelerated but not volatile.
*/
@Override
public ImageCapabilities getCapabilities(GraphicsConfiguration gc) {
if (isConfigValid(gc) && isAccelerationEnabled()) {
// accelerated but not volatile
return new ImageCapabilities(true);
}
// neither accelerated nor volatile
return new ImageCapabilities(false);
}
示例11: SunVolatileImage
import java.awt.ImageCapabilities; //导入依赖的package包/类
protected SunVolatileImage(Component comp,
GraphicsConfiguration graphicsConfig,
int width, int height, Object context,
int transparency, ImageCapabilities caps,
int accType)
{
this.comp = comp;
this.graphicsConfig = graphicsConfig;
if (width <= 0 || height <= 0) {
throw new IllegalArgumentException("Width (" + width + ")" +
" and height (" + height + ") cannot be <= 0");
}
this.width = width;
this.height = height;
this.forcedAccelSurfaceType = accType;
if (!(transparency == Transparency.OPAQUE ||
transparency == Transparency.BITMASK ||
transparency == Transparency.TRANSLUCENT))
{
throw new IllegalArgumentException("Unknown transparency type:" +
transparency);
}
this.transparency = transparency;
this.volSurfaceManager = createSurfaceManager(context, caps);
SurfaceManager.setManager(this, volSurfaceManager);
// post-construction initialization of the surface manager
volSurfaceManager.initialize();
// clear the background
volSurfaceManager.initContents();
}
示例12: testVolatileImage
import java.awt.ImageCapabilities; //导入依赖的package包/类
private static void testVolatileImage(GraphicsConfiguration cfg,
boolean accelerated)
{
VolatileImage dst = null;
try {
dst = cfg.createCompatibleVolatileImage(640, 480,
new ImageCapabilities(accelerated));
} catch (AWTException e) {
System.out.println("Unable to create volatile image, skip the test.");
return;
}
renderToVolatileImage(dst);
}
示例13: createBS
import java.awt.ImageCapabilities; //导入依赖的package包/类
private void createBS(boolean requestVSync) {
if (bs != null && requestVSync == currentBSVSynced) {
return;
}
BufferCapabilities bc = defaultBC;
if (requestVSync) {
bc = new sun.java2d.pipe.hw.ExtendedBufferCapabilities(
new ImageCapabilities(true),
new ImageCapabilities(true),
FlipContents.COPIED,
sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.VSYNC_ON);
}
try {
createBufferStrategy(2, bc);
} catch (AWTException e) {
System.err.println("Warning: cap is not supported: "+bc);
e.printStackTrace();
createBufferStrategy(2);
}
currentBSVSynced = requestVSync;
bs = getBufferStrategy();
String s =
getParent() instanceof Frame ?
((Frame)getParent()).getTitle() : "parent";
System.out.println("Created BS for \"" + s + "\" frame, bs="+bs);
}