Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何制作图像的缩略图或如何找到图像的路径_Java_Image_Path_Get_Thumbnails - Fatal编程技术网

Java 如何制作图像的缩略图或如何找到图像的路径

Java 如何制作图像的缩略图或如何找到图像的路径,java,image,path,get,thumbnails,Java,Image,Path,Get,Thumbnails,我有两个与拖放连接的面板 在左侧面板中,我创建了带有如下小图片的JLabel: ImageIcon ico =new ImageIcon("C:\\Documents and Settings\\student\\workspace\\DragTest3\\src\\drzewo.png");; p1.add(new JLabel(new ImageIcon(((new ImageIcon(ico.getDescription())).getImage()).getScaledInst

我有两个与拖放连接的面板

在左侧面板中,我创建了带有如下小图片的JLabel:

ImageIcon ico =new ImageIcon("C:\\Documents and Settings\\student\\workspace\\DragTest3\\src\\drzewo.png");;
    p1.add(new JLabel(new ImageIcon(((new ImageIcon(ico.getDescription())).getImage()).getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH))));  
删除JLabel后的代码:

ImageIcon ico = (ImageIcon)src.draggingLabel.getIcon();     
label=new JLabel(new ImageIcon(((new ImageIcon(ico.getImage()).getImage()).getScaledInstance(60, 60, java.awt.Image.SCALE_SMOOTH)))); 
但在我右侧面板上的图像中,我看到了像素

是否有可能获取此图像的原始路径? 或者知道如何在JLabel上缩放图像图标吗?


我可能会补充说,尽管有类似的问题,但我在这个论坛上还没有找到解决方案,所以请不要保留我的问题

您需要以某种方式将原始路径与标签相关联,最有可能的方式是创建自己的标签子类,将路径存储在其中。然后,您可以在获取drop事件时从标签查询路径


您还可以使用
ImageIO
加载到
BuffereImage
中,这样您就可以更强大地控制图像了。

所以当我这样做时:'ImageIcon ico=(ImageIcon)src.draggingLabel.getIcon();BuffereImage imgg=(BuffereImage)ico.getImage();'现在可以从BuffereImage获取路径了吗?你看到getPath方法了吗?BuffereImage表示图像,它们可能来自任何地方,甚至是动态生成的。它们没有路径或文件信息。