Scale « Icon Image « Java Swing Q&A





1. Resize Image in Java. How to resize    stackoverflow.com

I am trying to display an image on a Frame, however the image doesn't fit exactly on the frame. How can I resize the image? I cannot resize the frame. I ...

2. Swing: resize Image but keep same size    stackoverflow.com

I want to be able to do something similar to resize canvas in gimp I want to generate a bunch of images to a certain width. I used

int width = (int)(size * ...

3. image scaling error    coderanch.com

Hi, I have a program where I scale pictures. I wrote a methode for this action. I call this method two times, but one of the pictures has always strange stribes. If I call a Thread.sleep() between the two method calls, the pictures look fine. If I call the method only once, the one picture is fine, too. Can you help ...

4. how to scale an image?    coderanch.com

5. Scale the image    coderanch.com

I have this problem, please provide me with some suggestions. Imagine i have a rectangle of 374*378 and an image is loaded into that rectangle , now when a user clicks anywhere on that image , i will retrieve that point(upto this i am able to solve the problem).Now i have to make that point as center of the image and ...

7. Why can't I use getScaledInstance to scale images?    coderanch.com

Yes two things: 1 - You load a new image each time your paintComponent method calls drawImage. You only need to load the image one time so this line image = new ImageIcon("chi_wei.jpg").getImage(); belongs in your class constructor or a method called from it. 2 - in the test app below I originally put this line Image scaledImage = image.getScaledInstance((int)imageWidth, ...

8. Scaling image: black box until repainting    coderanch.com

Hi, I'm trying to load an image, rescale it, and draw it on a panel. After loading an Image and using getScaledInstance printed nothing, I read that one should use BufferedImage. However, the following code produces only a black box, until forcing a repaint by changing the size of the window or minimizing. class MyDrawPanel extends JPanel{ Image image = getToolkit().getImage("image.jpg"); ...

9. Image Scaling Issue    coderanch.com

I have run into a problem when moving some icon code to the newest JVM.. Before i did some scaling on icons and they were very crisp and smooth.. now they look pixelated and not in great quality.. I am using Image.SCALE_SMOOTH and that gives me the best product but it is still not what it was before.. If anyone has ...





10. Caching & Scaling BufferedImage/Image?    coderanch.com

What are the advantages of using Image over BufferedImage Objects? A BufferedImage is an Image. In fact, Image itself is abstract and can never be instantiated, so in that sense you can't. In order to use an Image, you'll have to use a subclass such as BufferedImage, thus comparing BufferedImage to Image is erroneous. The proper question would be "What are ...

11. Aspect ratio-preserving image scaling, drawing and infinite loops    coderanch.com

Hi, I want to be able to resize an image to fit within the bounds of a component (e.g., a JPanel) while preserving the original aspect ratio. To experiment, I adapted an example from the Head First Java (2ed) book, SimpleGui2B (p. 365), and wrote a method for MyDrawPanel to determine the dimensions of the image and the enclosing JPanel, and ...

12. Image scaling challenge    coderanch.com

13. Image scaling    coderanch.com

14. Scaling the Image.    coderanch.com

I need to draw line for coordinate -157,-132,31(Natural Coordinates). But its not displaying in the screen. How to bring it inside the view??? /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package tooltip; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.behaviors.mouse.MouseRotate; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.geometry.Sphere; import com.sun.j3d.utils.universe.SimpleUniverse; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import ...

15. Line appears in image after scaling    coderanch.com

16. Gray scale unformatted images    coderanch.com

I'm really new at Java coming over from C/C++ and know little about GUIs so far. I'll probably use JavaBeans or jEdit for the project I have after I learn more basic java. For part of the GUI I will need to display an image. The pixels are bytes, that is, one byte is one pixel, and are gray scale. No ...





17. Image scaling problem    coderanch.com

Hi! I would like to add Image scaling method to my SWING application. I am using the following code to zoom in/out images: private void doZoom(int scaleFactor) { Component[] c = MainClass.getSelectablePanel().getComponents(); for(int i = 0; i < c.length; i++) { if(c[i] instanceof JLabel) { JLabel selectedLabel = (JLabel)c[i]; ImageIcon newIcon = (ImageIcon) selectedLabel.getIcon(); Image img = newIcon.getImage(); Image newImg = ...

18. How to Scale an Image with the help of Affine Transformation?    java-forums.org

hi, i need to scale up/down an image(java image object).the image is created as : img=ImageIO.read(f) where 'img' is the java image object and 'f' is a image file from the hard disk. is it possible to do it with the help of affine transformation? i studied some examples but they are related with drawing an image in the frame with ...

19. The problem with scaling images    java-forums.org

private void doZoom(int scaleFactor) { Component[] c = MainClass.getSelectablePanel().getComponents(); for(int i = 0; i < c.length; i++) { if(c[i] instanceof JLabel) { JLabel selectedLabel = (JLabel)c[i]; ImageIcon newIcon = (ImageIcon) selectedLabel.getIcon(); selectedLabel.setIcon(scale(newIcon.getImage(), 0.75)); } } repaint(); } private ImageIcon scale(Image src, double scale) { int w = (int)(scale*src.getWidth(this)); int h = (int)(scale*src.getHeight(this)); int type = BufferedImage.TYPE_INT_RGB; BufferedImage dst = new BufferedImage(w, ...

20. How to scale an image to desired size?    java-forums.org