Examples of createCompatibleImage()


Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

     * @param bounds
     * @return BufferedImage
     */
    private BufferedImage getImage(Rectangle bounds) {
      GraphicsConfiguration gc = getGraphicsConfiguration();
      BufferedImage textImage = gc.createCompatibleImage(bounds.width, bounds.height, Transparency.TRANSLUCENT);
      return textImage;
    }

    /**
     * Returns the default GraphicsConfiguration.
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

   
    public static int getPreferedBufferedImageType(){
    GraphicsDevice[] graphicsDevices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    GraphicsDevice graphicsDevice = graphicsDevices[0];
    GraphicsConfiguration graphicsConfiguration = graphicsDevice.getConfigurations()[0];
    return graphicsConfiguration.createCompatibleImage(1, 1).getType();
  }
 
  public static int getPixelFormatFromBufferedImageType(int bufferedImageType){
    final int pixelFormat;
        switch (bufferedImageType){
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

        {
            GraphicsEnvironment ge = GraphicsEnvironment
                    .getLocalGraphicsEnvironment();
            GraphicsDevice gd = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            return gc.createCompatibleImage(width, height,
                    Transparency.TRANSLUCENT);
        }

        public BufferedImage getGrayscaleBufferedImage(int width, int height,
                boolean hasAlpha)
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

    final int height = Math.min(MAP_HEIGHT, mapHeight * scale);
   
    // this.getGraphicsConfiguration is not thread safe
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    // create the map image, and fill it with the wanted details
    final Image newMapImage  = gc.createCompatibleImage(mapWidth * scale, mapHeight * scale);
    final Graphics g = newMapImage.getGraphics();
    g.setColor(COLOR_BACKGROUND);
    g.fillRect(0, 0, mapWidth * scale, mapHeight * scale);
   
    for (int x = 0; x < mapWidth; x++) {
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

   */
  public Sprite createAchievementBox(String title, String description, String category) {
    final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    // Get the category image
    // initialize category image with empty image in case loading the image fails
    BufferedImage categoryImage = gc.createCompatibleImage(32, 32, Transparency.BITMASK);
    String imageName = ACHIEVEMENT_IMAGE_FOLDER + category.toLowerCase(Locale.ENGLISH) + ".png";
    try {
      categoryImage = ImageIO.read(AchievementBoxFactory.class.getClassLoader().getResourceAsStream(imageName));
    } catch (IOException e) {
      Logger.getLogger(AchievementBoxFactory.class).error("Error loading achievement box image: " + imageName, e);
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

    int height = (int) Math.max(categoryImage.getHeight(), (titleRect.getHeight() + textRect.getHeight()));
    width += 2 * SIDE_MARGIN + IMAGE_PAD;
    height += TOP_MARGIN + BOTTOM_MARGIN;
   
    // Create the background sprite
    final BufferedImage image = gc.createCompatibleImage(width, height, Transparency.BITMASK);
    final Graphics2D g2d = image.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setComposite(AlphaComposite.Src);
    BackgroundPainter bp = new BackgroundPainter(BACKGROUND);
    bp.paint(g2d, width, height);
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

      imageWidth = width + BUBBLE_OFFSET + ARC_DIAMETER;
    }
   
    final int imageHeight = LINE_HEIGHT * numLines + MARGIN_WIDTH;

    final BufferedImage image = gc.createCompatibleImage(imageWidth, imageHeight, Transparency.BITMASK);

    final Graphics2D g2d = image.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    if (fillColor != null) {
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

  private static void createIcons() {
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    Image bg = createIconBackground(gc);
   
    // copy bg for drawing
    Image image = gc.createCompatibleImage(TITLEBAR_HEIGHT, TITLEBAR_HEIGHT, Transparency.OPAQUE);
    Graphics g = image.getGraphics();
    g.drawImage(bg, 0, 0, null);
    closeIcon = createCloseIcon(image);
   
    // now we can draw over the background image
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

    /*
     * Full copy method (the memory hog)
     */
    final GraphicsConfiguration gc = getGC();

    final Image imageTemp = gc.createCompatibleImage(width, height,
        Transparency.BITMASK);

    draw(imageTemp.getGraphics(), 0, 0, x, y, width, height);

    return new ImageSprite(imageTemp, ref);
View Full Code Here

Examples of java.awt.GraphicsConfiguration.createCompatibleImage()

   * @param textColor Color of the text
   * @return TextSprite with the wanted text
   */
  public static TextSprite createTextSprite(String text, final Color textColor) {
    final GraphicsConfiguration gc = getGC();
    final Image image = gc.createCompatibleImage(graphics.getFontMetrics().stringWidth(
        text) + 2, 16, Transparency.BITMASK);
    final Graphics g2d = image.getGraphics();

    drawOutlineString(g2d, textColor, text, 1, 10);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.