Wednesday, November 28, 2007

Java CROP image Sample Code

Resource: http://www.java2s.com/Code/Java/2D-Graphics-GUI/Imagecrop.htm

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Crop extends JFrame {

  Image image;

  Insets insets;

  public Crop() {
    super();
    ImageIcon icon = new ImageIcon("wall2.jpg");
    image = icon.getImage();
    image = createImage(new FilteredImageSource( image.getSource(),
        //new CropImageFilter(73, 63, 141, 131)));
        new CropImageFilter(50, 30, 141, 131)));
  }

  public void paint(Graphics g) {
    super.paint(g);
    if (insets == null) {
      insets = getInsets();
    }
    g.drawImage(image, insets.left, insets.top, this);
  }

  public static void main(String args[]) {
    JFrame f = new Crop();
    f.setSize(600, 400);
    f.show();
  }
}

Centos 7 reset root/ any user lost password / lockout due to cant remember password

1. Need to be in front of the terminal. (Physically if not vm). 2. Reboot the server 3. Press 'e' in the GRUB2 boot screen. 3. bunch...