当前位置: 首页>>代码示例>>Java>>正文


Java Transparency类代码示例

本文整理汇总了Java中java.awt.Transparency的典型用法代码示例。如果您正苦于以下问题:Java Transparency类的具体用法?Java Transparency怎么用?Java Transparency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Transparency类属于java.awt包,在下文中一共展示了Transparency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createComponentCM

import java.awt.Transparency; //导入依赖的package包/类
/**
 * Create a {@code ComponentColorModel} for use in creating
 * an {@code ImageTypeSpecifier}.
 */
// This code was inspired by the method of the same name in
// javax.imageio.ImageTypeSpecifier
static ColorModel createComponentCM(ColorSpace colorSpace,
                                    int numBands,
                                    int[] bitsPerSample,
                                    int dataType,
                                    boolean hasAlpha,
                                    boolean isAlphaPremultiplied) {
    int transparency =
        hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;

    return new ComponentColorModel(colorSpace,
                                   bitsPerSample,
                                   hasAlpha,
                                   isAlphaPremultiplied,
                                   transparency,
                                   dataType);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TIFFDecompressor.java

示例2: D3DVolatileSurfaceManager

import java.awt.Transparency; //导入依赖的package包/类
public D3DVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    super(vImg, context);

    /*
     * We will attempt to accelerate this image only under the
     * following conditions:
     *   - the image is opaque OR
     *   - the image is translucent AND
     *       - the GraphicsConfig supports the FBO extension OR
     *       - the GraphicsConfig has a stored alpha channel
     */
    int transparency = vImg.getTransparency();
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        vImg.getGraphicsConfig().getDevice();
    accelerationEnabled =
        (transparency == Transparency.OPAQUE) ||
        (transparency == Transparency.TRANSLUCENT &&
         (gd.isCapPresent(CAPS_RT_PLAIN_ALPHA) ||
          gd.isCapPresent(CAPS_RT_TEXTURE_ALPHA)));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:D3DVolatileSurfaceManager.java

示例3: initSurfaceNow

import java.awt.Transparency; //导入依赖的package包/类
private boolean initSurfaceNow() {
    boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
    switch (type) {
        case RT_PLAIN:
            return initRTSurface(getNativeOps(), isOpaque);
        case TEXTURE:
            return initTexture(getNativeOps(), false/*isRTT*/, isOpaque);
        case RT_TEXTURE:
            return initTexture(getNativeOps(), true/*isRTT*/,  isOpaque);
        // REMIND: we may want to pass the exact type to the native
        // level here so that we could choose the right presentation
        // interval for the frontbuffer (immediate vs v-synced)
        case WINDOW:
        case FLIP_BACKBUFFER:
            return initFlipBackbuffer(getNativeOps(), peer.getData(),
                                      backBuffersNum, swapEffect,
                                      syncType.id());
        default:
            return false;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:D3DSurfaceData.java

示例4: initImage

import java.awt.Transparency; //导入依赖的package包/类
static void initImage(GraphicsConfiguration gc, Image image) {
    Graphics g = image.getGraphics();
    g.setColor(Color.RED);
    int w = image.getWidth(null);
    int h = image.getHeight(null);
    g.fillRect(0, 0, w, h);
    g.dispose();

    // need to 'accelerate' the image
    if (dstImage == null) {
        dstImage =
            gc.createCompatibleVolatileImage(TESTW, TESTH,
                                             Transparency.OPAQUE);
    }
    dstImage.validate(gc);
    g = dstImage.getGraphics();
    g.drawImage(image, 0, 0, null);
    g.drawImage(image, 0, 0, null);
    g.drawImage(image, 0, 0, null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SourceClippingBlitTest.java

示例5: getColorModel

import java.awt.Transparency; //导入依赖的package包/类
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:D3DGraphicsConfig.java

示例6: X11VolatileSurfaceManager

import java.awt.Transparency; //导入依赖的package包/类
public X11VolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    super(vImg, context);

    // We only accelerated opaque vImages currently
    accelerationEnabled = X11SurfaceData.isAccelerationEnabled() &&
        (vImg.getTransparency() == Transparency.OPAQUE);

    if ((context != null) && !accelerationEnabled) {
        // if we're wrapping a backbuffer drawable, we must ensure that
        // the accelerated surface is initialized up front, regardless
        // of whether acceleration is enabled. But we need to set
        // the  accelerationEnabled field to true to reflect that this
        // SM is actually accelerated.
        accelerationEnabled = true;
        sdAccel = initAcceleratedSurface();
        sdCurrent = sdAccel;

        if (sdBackup != null) {
            // release the system memory backup surface, as we won't be
            // needing it in this case
            sdBackup = null;
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:X11VolatileSurfaceManager.java

示例7: scaleSurfaceData

import java.awt.Transparency; //导入依赖的package包/类
protected boolean scaleSurfaceData(SunGraphics2D sg,
                                   Region clipRegion,
                                   SurfaceData srcData,
                                   SurfaceData dstData,
                                   SurfaceType srcType,
                                   SurfaceType dstType,
                                   int sx1, int sy1,
                                   int sx2, int sy2,
                                   double dx1, double dy1,
                                   double dx2, double dy2)
{
    CompositeType comp = sg.imageComp;
    if (CompositeType.SrcOverNoEa.equals(comp) &&
        (srcData.getTransparency() == Transparency.OPAQUE))
    {
        comp = CompositeType.SrcNoEa;
    }

    ScaledBlit blit = ScaledBlit.getFromCache(srcType, comp, dstType);
    if (blit != null) {
        blit.Scale(srcData, dstData, sg.composite, clipRegion,
                   sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:DrawImage.java

示例8: copyArea

import java.awt.Transparency; //导入依赖的package包/类
void copyArea(SunGraphics2D sg2d,
              int x, int y, int w, int h, int dx, int dy)
{
    rq.lock();
    try {
        int ctxflags =
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
                D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
        D3DSurfaceData dstData;
        try {
            dstData = (D3DSurfaceData)sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        D3DContext.validateContext(dstData, dstData,
                                   sg2d.getCompClip(), sg2d.composite,
                                   null, null, null, ctxflags);

        rq.ensureCapacity(28);
        buf.putInt(COPY_AREA);
        buf.putInt(x).putInt(y).putInt(w).putInt(h);
        buf.putInt(dx).putInt(dy);
    } finally {
        rq.unlock();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:D3DRenderer.java

示例9: testConstructor2

import java.awt.Transparency; //导入依赖的package包/类
private static void testConstructor2() {
    /*
     * verify equality with constructor
     * ComponentColorModel(ColorSpace colorSpace,
     *                  boolean hasAlpha,
     *                  boolean isAlphaPremultiplied,
     *                  int transparency,
     *                  int transferType)
     */
    ComponentColorModel model1 =
        new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                false,
                                false,
                                Transparency.OPAQUE,
                                DataBuffer.TYPE_BYTE);
    ComponentColorModel model2 =
        new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                false,
                                false,
                                Transparency.OPAQUE,
                                DataBuffer.TYPE_BYTE);
    verifyEquals(model1, model2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ComponentColorModelEqualsTest.java

示例10: copyArea

import java.awt.Transparency; //导入依赖的package包/类
void copyArea(SunGraphics2D sg2d,
              int x, int y, int w, int h, int dx, int dy)
{
    rq.lock();
    try {
        int ctxflags =
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
                OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
        OGLSurfaceData dstData;
        try {
            dstData = (OGLSurfaceData)sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        OGLContext.validateContext(dstData, dstData,
                                   sg2d.getCompClip(), sg2d.composite,
                                   null, null, null, ctxflags);

        rq.ensureCapacity(28);
        buf.putInt(COPY_AREA);
        buf.putInt(x).putInt(y).putInt(w).putInt(h);
        buf.putInt(dx).putInt(dy);
    } finally {
        rq.unlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:OGLRenderer.java

示例11: testConstructor1

import java.awt.Transparency; //导入依赖的package包/类
private static void testConstructor1() {
    /*
     * verify equality with constructor
     * ComponentColorModel(ColorSpace colorSpace,
     *                  int[] bits,
     *                  boolean hasAlpha,
     *                  boolean isAlphaPremultiplied,
     *                  int transparency,
     *                  int transferType)
     */
    ComponentColorModel model1 =
        new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                new int[] {8, 8, 8},
                                false,
                                false,
                                Transparency.OPAQUE,
                                DataBuffer.TYPE_BYTE);
    ComponentColorModel model2 =
        new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                new int[] {8, 8, 8},
                                false,
                                false,
                                Transparency.OPAQUE,
                                DataBuffer.TYPE_BYTE);
    verifyEquals(model1, model2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ComponentColorModelEqualsTest.java

示例12: CGLVolatileSurfaceManager

import java.awt.Transparency; //导入依赖的package包/类
public CGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    super(vImg, context);

    /*
     * We will attempt to accelerate this image only under the
     * following conditions:
     *   - the image is opaque OR
     *   - the image is translucent AND
     *       - the GraphicsConfig supports the FBO extension OR
     *       - the GraphicsConfig has a stored alpha channel
     */
    int transparency = vImg.getTransparency();
    CGLGraphicsConfig gc = (CGLGraphicsConfig)vImg.getGraphicsConfig();
    accelerationEnabled =
        (transparency == Transparency.OPAQUE) ||
        ((transparency == Transparency.TRANSLUCENT) &&
         (gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
          gc.isCapPresent(CAPS_STORED_ALPHA)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CGLVolatileSurfaceManager.java

示例13: WGLVolatileSurfaceManager

import java.awt.Transparency; //导入依赖的package包/类
public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    super(vImg, context);

    /*
     * We will attempt to accelerate this image only under the
     * following conditions:
     *   - the image is opaque OR
     *   - the image is translucent AND
     *       - the GraphicsConfig supports the FBO extension OR
     *       - the GraphicsConfig has a stored alpha channel
     */
    int transparency = vImg.getTransparency();
    WGLGraphicsConfig gc = (WGLGraphicsConfig)vImg.getGraphicsConfig();
    accelerationEnabled =
        (transparency == Transparency.OPAQUE) ||
        ((transparency == Transparency.TRANSLUCENT) &&
         (gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
          gc.isCapPresent(CAPS_STORED_ALPHA)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:WGLVolatileSurfaceManager.java

示例14: GLXVolatileSurfaceManager

import java.awt.Transparency; //导入依赖的package包/类
public GLXVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    super(vImg, context);

    /*
     * We will attempt to accelerate this image only under the
     * following conditions:
     *   - the image is opaque OR
     *   - the image is translucent AND
     *       - the GraphicsConfig supports the FBO extension OR
     *       - the GraphicsConfig has a stored alpha channel
     */
    int transparency = vImg.getTransparency();
    GLXGraphicsConfig gc = (GLXGraphicsConfig)vImg.getGraphicsConfig();
    accelerationEnabled =
        (transparency == Transparency.OPAQUE) ||
        ((transparency == Transparency.TRANSLUCENT) &&
         (gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
          gc.isCapPresent(CAPS_STORED_ALPHA)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:GLXVolatileSurfaceManager.java

示例15: createFloatBufferedImage

import java.awt.Transparency; //导入依赖的package包/类
BufferedImage createFloatBufferedImage(int w, int h, int bands) {
    // Define dimensions and layout of the image
    //int bands = 4; // 4 bands for ARGB, 3 for RGB etc
    int[] bandOffsets = {0, 1, 2, 3}; // length == bands, 0 == R, 1 == G, 2 == B and 3 == A

    // Create a TYPE_FLOAT sample model (specifying how the pixels are stored)
    SampleModel sampleModel = new PixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, w, h, bands, w  * bands, bandOffsets);
    // ...and data buffer (where the pixels are stored)
    DataBuffer buffer = new DataBufferFloat(w * h * bands);

    // Wrap it in a writable raster
    WritableRaster raster = Raster.createWritableRaster(sampleModel, buffer, null);

    // Create a color model compatible with this sample model/raster (TYPE_FLOAT)
    // Note that the number of bands must equal the number of color components in the 
    // color space (3 for RGB) + 1 extra band if the color model contains alpha 
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel colorModel = new ComponentColorModel(colorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_FLOAT);

    // And finally create an image with this raster
    return new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:23,代码来源:OpenCLWithJOCL.java


注:本文中的java.awt.Transparency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。