About 8,230 results
Open links in new tab
  1. Scale images as a single surface in Java 2D API

    Sep 27, 2014 · Try the SCALE_AREA_AVERAGING and the SCALE_SMOOTH for nicer scaled images. // Scaled 3 times: Image img2 = img.getScaledInstance(img.getWidth(null)*3, img.getHeight(null)*3, Image.SCALE_AREA_AVERAGING); // Tip: you should cache the scaled image and not scale it in the paint() method!

  2. Java Graphics2D Translate and Scale - Stack Overflow

    Jun 11, 2015 · Here's the code I have so far to do it: AffineTransform t = new AffineTransform(); float a = 400 - player.getX(); float b = 250 - player.getY(); t.translate(a, b); /* * Here's where I want to scale using the zoom. * variable and also translate the g2d according. * to the zoom variable. */ return t; zoom += e.getPreciseWheelRotation();

  3. java - How do you use re-size all Graphic2D - Stack Overflow

    Dec 12, 2014 · For this you can use the Graphics2D.scale(double,double), Graphics2D.rotate(double), Graphics2D.translate(double,double) and Graphics2D.shear(double,double) methods. So if you first call. g2d.scale(2.0,2.0); then all your graphics that you subsequently draw will be twice as large in both directions.

  4. How Can I Resize an Image Using Java? - Baeldung

    Mar 26, 2025 · Core Java offers the following options for resizing images: Graphics2D is the fundamental class for rendering 2-dimensional shapes, text, and images on the Java platform. Let’s start by resizing an image using Graphics2D: BufferedImage resizedImage = new BufferedImage (targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);

  5. Transforming Shapes, Text, and Images (The Java™ Tutorials > 2D ...

    You can modify the transform attribute in the Graphics2D context to move, rotate, scale, and shear graphics primitives when they are rendered. The transform attribute is defined by an instance of the AffineTransform class.

  6. How to Properly Scale a BufferedImage in Java - CodingTechRoom

    Scaling a BufferedImage in Java requires a method to preserve the quality and content of the image. The Graphics2D class provides ways to draw and manipulate images but simply scaling it does not resize the entire image content as intended.

  7. 3 Ways to Resize Images in Java - Cloudinary

    Apr 11, 2025 · Java provides several techniques for programmatic bulk image resize, including the getScaledInstance () method and the Graphics2D class. We’ll also show how to use Cloudinary to resize images in Java while automatically adjusting the …

  8. Graphics2D (Java Platform SE 8 ) - Oracle

    This Graphics2D class extends the Graphics class to provide more sophisticated control over geometry, coordinate transformations, color management, and text layout. This is the fundamental class for rendering 2-dimensional shapes, text and images on …

  9. Scale image in Java and preserve its quality

    Jun 8, 2020 · From the core Java features, there are two main ways to scale image - using Graphics2D and Image.getScaledInstance(). They provide us with certain configuration options called "hints" that can help us balance between processing time and output image quality.

  10. java - Scale an image with Graphics2D - Stack Overflow

    May 4, 2013 · I have a image of a crate that I want to be draw bigger than I have drawn it. Then I want the image to become progressively smaller with times so that it looks like it's dropped from the air. I have crafted this code which I think should work but for some reason it doesn't.