Total members 10261 | Gratitudes |It is currently Tue May 22, 2012 5:04 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: Image Scale in java
PostPosted: Tue Nov 11, 2008 8:04 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Image Scale in java
Code:
import java.awt.*;
import javax.swing.*;

public class ImageScale extends JFrame {
  Image image;
  Insets insets;
  public ImageScale() {
    super("Show Image Scales");
    ImageIcon imageIcon = new ImageIcon("image4.jpg");
    image = imageIcon.getImage();
  }
  public void paint(Graphics g) {
    super.paint(g);
    if (insets == null) {
      insets = getInsets();
    }
    g.drawImage(image, insets.left, insets.top, this);
  }
  public void scale() {
    reset();
    Image img = image;
    image = img.getScaledInstance(250, -1, Image.SCALE_FAST);
    repaint();
    reset();
   
    image = img.getScaledInstance(300, -1, Image.SCALE_SMOOTH);
    repaint();
    reset();
   
    image = img.getScaledInstance(450, -1, Image.SCALE_REPLICATE);
    repaint();
    reset();
   
    image = img.getScaledInstance(400, -1, Image.SCALE_DEFAULT);
    repaint();
    reset();
  image = img.getScaledInstance(350, -1, Image.SCALE_AREA_AVERAGING);
  repaint();
    reset();
    System.exit(0);
  }
  private void reset() {
    try {
      Thread.sleep(3000);
    } catch (Exception e) {}
  }
  public static void main(String args[]) {
    ImageScale imgScale = new ImageScale();
    imgScale.setSize(400, 200);
    imgScale.show();
    imgScale.scale();
  }
}


Attachments:
File comment: image Scales in java
imageScales.gif
imageScales.gif [ 18.99 KiB | Viewed 6273 times ]

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 video chat application in java
 Image Insert in Excel File Using POI
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 image processing
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team