hi,
goal: resizing an image by moving the JSlider's needle.
not working: i resizing work just fine, but outputing the image to simple jPanel doesn't work properly. It resizes and displays the image as long as the the mouse button is NOT release. If done, the image disapears.
jPanelPicture.removeAll();
and
jPanelPciture.repaint();
didn't help?
any clue how this works?
cheers
public void resizeImage(){
//---Bildbearbeitung---
String file1 = "a.jpg";
RenderedImage source = JAI.create("fileload", file1);
ParameterBlock pb = new ParameterBlock();
/*pb.addSource(source);
pb.add(null).add(null).add(null).add(null).add(null);
RenderableImage ren = JAI.createRenderable("renderable", pb);
int h = source.getHeight();
int w = source.getWidth();
PlanarImage dst = (PlanarImage) ren.createScaledRendering(w, h, null);
*/
//verkleinerungsfaktor
float resizeFactor = (float)jSliderVerkleinerung.getValue() / 100;
String strPercent = String.valueOf(jSliderVerkleinerung.getValue());
jLabelSliderValue.setText(strPercent + "%");
if(resizeFactor == 0.00F)
resizeFactor = 0.01F;
//verkleinern
pb = new ParameterBlock();
pb.addSource(source);
pb.add(resizeFactor); // 0.3 is just some test data
pb.add(resizeFactor);
pb.add(0.0f);
pb.add(0.0f);
pb.add(new InterpolationNearest());// <-- this is the key
PlanarImage img = JAI.create("scale", pb, null);
DisplayJAI dj = new DisplayJAI(img);
jPanelPicture.removeAll();
jPanelPicture.add(dj);
jPanelPicture.repaint();
}
goal: resizing an image by moving the JSlider's needle.
not working: i resizing work just fine, but outputing the image to simple jPanel doesn't work properly. It resizes and displays the image as long as the the mouse button is NOT release. If done, the image disapears.
jPanelPicture.removeAll();
and
jPanelPciture.repaint();
didn't help?
any clue how this works?
cheers
public void resizeImage(){
//---Bildbearbeitung---
String file1 = "a.jpg";
RenderedImage source = JAI.create("fileload", file1);
ParameterBlock pb = new ParameterBlock();
/*pb.addSource(source);
pb.add(null).add(null).add(null).add(null).add(null);
RenderableImage ren = JAI.createRenderable("renderable", pb);
int h = source.getHeight();
int w = source.getWidth();
PlanarImage dst = (PlanarImage) ren.createScaledRendering(w, h, null);
*/
//verkleinerungsfaktor
float resizeFactor = (float)jSliderVerkleinerung.getValue() / 100;
String strPercent = String.valueOf(jSliderVerkleinerung.getValue());
jLabelSliderValue.setText(strPercent + "%");
if(resizeFactor == 0.00F)
resizeFactor = 0.01F;
//verkleinern
pb = new ParameterBlock();
pb.addSource(source);
pb.add(resizeFactor); // 0.3 is just some test data
pb.add(resizeFactor);
pb.add(0.0f);
pb.add(0.0f);
pb.add(new InterpolationNearest());// <-- this is the key
PlanarImage img = JAI.create("scale", pb, null);
DisplayJAI dj = new DisplayJAI(img);
jPanelPicture.removeAll();
jPanelPicture.add(dj);
jPanelPicture.repaint();
}