我做了一个java rmi based application,我传递并从服务器接收一个ImageIcon对象...
(图像存储在服务器中的单独URL中)
该功能涉及以下内容....
1. Getting the image from the server at first....(on button press A)
2. Replacing it with a image file in the client[optional]....(on button press B)
3. Remove the image with a default image[optional]....(on button press C)
4. Sending it back to the Server....................(On button press D).....此处图像显示在一个名为img_label的jlabel中
我使用的代码如下.....
使用的变量
java.awt.Image img;
javax.swing.ImageIcon CurrentImageIcon;
javax.swing.ImageIcon DefaultImageIcon;
// CurrentImageIcon contains the image to be displayed in the img_label....
// img is used for copying as well for scaling......
// DefaultImageIcon holds the default Image......在按钮上按A键
img = temp.getImage();
CurrentImageIcon = new ImageIcon(img);
// Assuming temp holds the ImageIcon taken from the server.......
img=img.getScaledInstance(83,85 , Image.SCALE_DEFAULT);
img_label.setIcon(new ImageIcon(img));
img_label.revalidate();
img_label.repaint();按下按钮B
String url_text = jTextField.getText(); // taking the url frm the field.....
CurrentImageIcon = new ImageIcon(url_text);
img=CurrentImageIcon.getImage();
img=img.getScaledInstance(83,85 , Image.SCALE_DEFAULT);
img_label.setIcon(new ImageIcon(img));
img_label.revalidate();
img_label.repaint();按下按钮C
img = DefaultImageIcon.getImage();
CurrentImageIcon = new ImageIcon(img);
img=img.getScaledInstance(83,85 , Image.SCALE_DEFAULT);
img_label.setIcon(new ImageIcon(img));
img_label.revalidate();
img_label.repaint();在按钮上按D键
// ImagetoSend is an ImageIcon to be sent to the Server.....
ImagetoSend = CurrentImageIcon;
CurrentImageIcon = null;现在我得到的问题是一个奇怪的......
图像越来越嵌入,因为我想重新绘制时,我点击这个按钮........
But when i download the recently uploaded image next time on Button press A....it is displayed either magnified or reduced to size even though i included the getScaledInstance method....
喜欢这个...
我正在处理的图像是一个jpg图像....
我甚至在服务器目录中检查了镜像.....从客户端上传到服务器的文件没有发生大小变化。但是当它被下载并嵌入到jlabel中时,就会观察到这种变化...
任何人都可以帮我解决这个问题......?