當前位置: 首頁>>代碼示例>>Java>>正文


Java Transparency.OPAQUE屬性代碼示例

本文整理匯總了Java中java.awt.Transparency.OPAQUE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Transparency.OPAQUE屬性的具體用法?Java Transparency.OPAQUE怎麽用?Java Transparency.OPAQUE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.Transparency的用法示例。


在下文中一共展示了Transparency.OPAQUE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: copyArea

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,代碼行數:26,代碼來源:OGLRenderer.java

示例2: GLXVolatileSurfaceManager

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,代碼行數:19,代碼來源:GLXVolatileSurfaceManager.java

示例3: SunVolatileImage

private SunVolatileImage(Component comp,
                         GraphicsConfiguration graphicsConfig,
                         int width, int height, Object context,
                         ImageCapabilities caps)
{
    this(comp, graphicsConfig,
         width, height, context, Transparency.OPAQUE, caps, UNDEFINED);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:SunVolatileImage.java

示例4: canRenderLCDText

/**
 * For now, we can only render LCD text if:
 *   - the pixel shaders are available, and
 *   - blending is disabled, and
 *   - the source color is opaque
 *   - and the destination is opaque
 */
public boolean canRenderLCDText(SunGraphics2D sg2d) {
    return
        graphicsDevice.isCapPresent(CAPS_LCD_SHADER) &&
        sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
        sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR   &&
        sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:D3DSurfaceData.java

示例5: findColorIndex

protected int findColorIndex(ColorNode aNode, Color aColor) {
    if (transparency != Transparency.OPAQUE &&
        aColor.getAlpha() != 0xff)
    {
        return 0; // default transparnt pixel
    }

    if (aNode.isLeaf) {
        return aNode.paletteIndex;
    } else {
        int childIndex = getBranchIndex(aColor, aNode.level);

        return findColorIndex(aNode.children[childIndex], aColor);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:PaletteBuilder.java

示例6: createData

/**
 * Creates a SurfaceData object representing an off-screen buffer (either
 * a plain surface or Texture).
 */
public static D3DSurfaceData createData(D3DGraphicsConfig gc,
                                        int width, int height,
                                        ColorModel cm,
                                        Image image, int type)
{
    if (type == RT_TEXTURE) {
        boolean isOpaque = cm.getTransparency() == Transparency.OPAQUE;
        int cap = isOpaque ? CAPS_RT_TEXTURE_OPAQUE : CAPS_RT_TEXTURE_ALPHA;
        if (!gc.getD3DDevice().isCapPresent(cap)) {
            type = RT_PLAIN;
        }
    }
    D3DSurfaceData ret = null;
    try {
        ret = new D3DSurfaceData(null, gc, width, height,
                                 image, cm, 0, SWAP_DISCARD, VSYNC_DEFAULT,
                                 type);
    } catch (InvalidPipeException ipe) {
        // try again - we might have ran out of vram, and rt textures
        // could take up more than a plain surface, so it might succeed
        if (type == RT_TEXTURE) {
            // If a RT_TEXTURE was requested do not attempt to create a
            // plain surface. (note that RT_TEXTURE can only be requested
            // from a VI so the cast is safe)
            if (((SunVolatileImage)image).getForcedAccelSurfaceType() !=
                RT_TEXTURE)
            {
                type = RT_PLAIN;
                ret = new D3DSurfaceData(null, gc, width, height,
                                         image, cm, 0, SWAP_DISCARD,
                                         VSYNC_DEFAULT, type);
            }
        }
    }
    return ret;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:40,代碼來源:D3DSurfaceData.java

示例7: isSupportedOperation

@Override
public boolean isSupportedOperation(SurfaceData srcData,
                                    int txtype,
                                    CompositeType comp,
                                    Color bgColor)
{
    return comp.isDerivedFrom(CompositeType.AnyAlpha) &&
           (bgColor == null || transparency == Transparency.OPAQUE);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:OGLSurfaceDataProxy.java

示例8: isBgOperation

protected static boolean isBgOperation(SurfaceData srcData, Color bgColor) {
    // If we cannot get the srcData, then cannot assume anything about
    // the image
    return ((srcData == null) ||
            ((bgColor != null) &&
             (srcData.getTransparency() != Transparency.OPAQUE)));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:DrawImage.java

示例9: getColorModel

/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        return getColorModel();
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:X11GraphicsConfig.java

示例10: createProxy

public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:X11SurfaceDataProxy.java

示例11: imageToPlatformBytes

@Override
protected byte[] imageToPlatformBytes(Image image, long format)
        throws IOException {
    String mimeType = null;
    if (format == CF_PNG) {
        mimeType = "image/png";
    } else if (format == CF_JFIF) {
        mimeType = "image/jpeg";
    }
    if (mimeType != null) {
        return imageToStandardBytes(image, mimeType);
    }

    int width = 0;
    int height = 0;

    if (image instanceof ToolkitImage) {
        ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
        ir.reconstruct(ImageObserver.ALLBITS);
        width = ir.getWidth();
        height = ir.getHeight();
    } else {
        width = image.getWidth(null);
        height = image.getHeight(null);
    }

    // Fix for 4919639.
    // Some Windows native applications (e.g. clipbrd.exe) do not handle
    // 32-bpp DIBs correctly.
    // As a workaround we switched to 24-bpp DIBs.
    // MSDN prescribes that the bitmap array for a 24-bpp should consist of
    // 3-byte triplets representing blue, green and red components of a
    // pixel respectively. Additionally each scan line must be padded with
    // zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
    // We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
    // with non-default scanline stride and pass the resulting data buffer
    // to the native code to fill the BITMAPINFO structure.
    int mod = (width * 3) % 4;
    int pad = mod > 0 ? 4 - mod : 0;

    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = {8, 8, 8};
    int[] bOffs = {2, 1, 0};
    ColorModel colorModel =
            new ComponentColorModel(cs, nBits, false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    WritableRaster raster =
            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
                    width * 3 + pad, 3, bOffs, null);

    BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);

    // Some Windows native applications (e.g. clipbrd.exe) do not understand
    // top-down DIBs.
    // So we flip the image vertically and create a bottom-up DIB.
    AffineTransform imageFlipTransform =
            new AffineTransform(1, 0, 0, -1, 0, height);

    Graphics2D g2d = bimage.createGraphics();

    try {
        g2d.drawImage(image, imageFlipTransform, null);
    } finally {
        g2d.dispose();
    }

    DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();

    byte[] imageData = buffer.getData();
    return imageDataToPlatformImageBytes(imageData, width, height, format);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:71,代碼來源:WDataTransferer.java

示例12: getTransparency

public int getTransparency() {
    return Transparency.OPAQUE;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:3,代碼來源:X11SurfaceDataProxy.java

示例13: getTransparency

public int getTransparency() {
    return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:3,代碼來源:CGLLayer.java

示例14: Blit

static void Blit(SurfaceData srcData, SurfaceData dstData,
                 Composite comp, Region clip,
                 AffineTransform xform, int hint,
                 int sx1, int sy1,
                 int sx2, int sy2,
                 double dx1, double dy1,
                 double dx2, double dy2,
                 int srctype, boolean texture)
{
    int ctxflags = 0;
    if (srcData.getTransparency() == Transparency.OPAQUE) {
        ctxflags |= OGLContext.SRC_IS_OPAQUE;
    }

    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        // make sure the RenderQueue keeps a hard reference to the
        // source (sysmem) SurfaceData to prevent it from being
        // disposed while the operation is processed on the QFT
        rq.addReference(srcData);

        OGLSurfaceData oglDst = (OGLSurfaceData)dstData;
        if (texture) {
            // make sure we have a current context before uploading
            // the sysmem data to the texture object
            OGLGraphicsConfig gc = oglDst.getOGLGraphicsConfig();
            OGLContext.setScratchSurface(gc);
        } else {
            OGLContext.validateContext(oglDst, oglDst,
                                       clip, comp, xform, null, null,
                                       ctxflags);
        }

        int packedParams = createPackedParams(false, texture,
                                              false, xform != null,
                                              hint, srctype);
        enqueueBlit(rq, srcData, dstData,
                    packedParams,
                    sx1, sy1, sx2, sy2,
                    dx1, dy1, dx2, dy2);

        // always flush immediately, since we (currently) have no means
        // of tracking changes to the system memory surface
        rq.flushNow();
    } finally {
        rq.unlock();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:49,代碼來源:OGLBlitLoops.java

示例15: grabPixels

/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:66,代碼來源:JPEGImageWriter.java


注:本文中的java.awt.Transparency.OPAQUE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。