Zmiana rozmiaru i wyświetlanie obrazu w JPanel lub JLabel bez utraty jakości

Opracowuję program java do przechwytywania obrazów pracowników podczas rejestracji za pomocą kamery internetowej. Mogę uzyskać obraz bez problemu i zapisać go na dysku C: ale po odzyskaniu obrazu tylko część obrazu jest wyświetlana na etykiecie. Czy istnieje sposób zmiany rozmiaru pliku JPEG przed jego zapisaniem? lub przed wyświetleniem? jak kurczenie się bez utraty jakości ....

Dziękuję bardzo Cheerz! :)!

OK, chłopaki ... tu idzie: - Skomentowałem kod w sposób, w jaki ich użyłem.

//This method will capture the image from the interface and save it under the unique employee ID
public String captureImage(int picId){

    FrameGrabbingControl ControlFG = (FrameGrabbingControl)

    broadcast.getControl("javax.media.control.FrameGrabbingControl");

    Buffer buffer = ControlFG.grabFrame();

    BufferToImage image = new BufferToImage((VideoFormat)buffer.getFormat());

    img = image.createImage(buffer);

    path="c:\\employee"+picId+".jpg";

    saveJPG(img,path);//method will save the image

    return path;

}

 public void saveJPG(Image img, String s){***//method will save the image***

    System.out.println(s);

    BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null),

    BufferedImage.TYPE_INT_RGB);

    Graphics2D g2 = bi.createGraphics();

    g2.drawImage(img,null,null);

    FileOutputStream out = null;
    try{

    out = new FileOutputStream(s);

    }
    catch (java.io.FileNotFoundException io){

    System.out.println("File Not Found");
    }

    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);

    param.setQuality(0.5f,false);

    encoder.setJPEGEncodeParam(param);

    try
    {
    encoder.encode(bi);
    out.close();
    }

    catch (java.io.IOException io)
    {
    System.out.println("IOException");
    }
    }

może mogę przeskalować obraz podczas zapisywania .., abym mógł pobrać skalowany obraz ..

questionAnswers(1)

yourAnswerToTheQuestion