导航:首页 > 动漫图片 > java中怎么读取图片

java中怎么读取图片

发布时间:2023-01-09 19:54:31

Ⅰ 在JAVA中如何将图片从数据库读取到页面上

这是用Struts做的
<img src="<bean:write name="item" property="page"/>" width="100" height="100">

图片文件夹必须在服务器里

Ⅱ java 怎样从磁盘读取图片文件

用JFileChoose 这个类,用来选择文件 主要代码如下:
JFileChooser f = new JFileChooser(); // 查找文件
f.setFileFilter(new FileNameExtensionFilter("图片文件(*.bmp, *.gif, *.jpg, *.jpeg, *.png)", "bmp", "gif","jpg", "jpeg", "png"));
int rVal = f.showOpenDialog(null);

Ⅲ 用java怎么读取图片

思路:使用 java.awt.Image包下的Image可以接收图片。读取则使用ImageIO对象。

代码如下:

/**
* 读取图片,首先导入以下的包
*/
import java.awt.Image;
import javax.imageio.ImageIO;
import java.io.*;

/**
* 用Image对象来接收图片
* 路径根据实际情况修改
*/
Image image = ImageIO.read(new File("c:\\1.png"));
System.out.println(image.getSource());

Ⅳ 请教如何用Java语言读取jpg图片,并显示

1、获取文件夹的路径 2、得到文件夹中的有图片的名称,可以存到数组或者集合中 3、你再到jsp页面做显示, 4、下面是获取路径和文件名的代码,前台显示的代码自己写 String path = 文件夹路径; String names = ""; try { File f = new File(path)

Ⅳ Java如何读取文件夹中所有图片,并显示出来

说一下思路吧,首先遍历文件夹,找到对应后缀的文件(png,jpg之类的),然后创建Bitmap对象,使用inputStream将文件转成bitmap对象,之后使用imageview或者GLview显示图片即可。
注意对大图进行压缩,结束时图片必须回收处理,bitmap.recycle()否则图片多了内存溢出

Ⅵ 求助一下关于java怎么读取图片路径

图像放错地方了,最好是放在根目录下面(reboot下面),搜寻时从根目录开始的,直接把image放在这里就可以了。

Ⅶ java读取图片问题

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.*;

public class Test{
public static void main(String args[]) {
int[] rgb = new int[3];

File file = new File("a.bmp");
BufferedImage bi=null;
try{
bi = ImageIO.read(file);
}catch(Exception e){
e.printStackTrace();
}

int width=bi.getWidth();
int height=bi.getHeight();
int minx=bi.getMinX();
int miny=bi.getMinY();
System.out.println("width="+width+",height="+height+".");
System.out.println("minx="+minx+",miniy="+miny+".");

for(int i=minx;i<width;i++){
for(int j=miny;j<height;j++){
//System.out.print(bi.getRGB(jw, ih));
int pixel=bi.getRGB(i, j);
rgb[0] = (pixel & 0xff0000 ) >> 16 ;
rgb[1] = (pixel & 0xff00 ) >> 8 ;
rgb[2] = (pixel & 0xff );
System.out.println("i="+i+",j="+j+":("+rgb[0]+","+rgb[1]+","+rgb[2]+")");

}
}

}

}

Ⅷ Java中怎么抓取网页中的图片

通过httpclient来爬取网站内容,分析当前内容页中的图片‘规则’
抓取一般都是模拟浏览器访问目标网页,通过返回的页面html代码进行分析自己需要的数据
查找规则,例如你爬取的网页 ,看到当前页面显示的图片格式如下<img src="http://www..com/img/20101025_user.png">
通过解析爬取的网页源代码(html)进行字符串的操作即可,现在有相应的第三方jar包可以帮你更快的完成这部分工作,例如htmlpaser,获取到对应的地址,然后进行保存或下载。
你可以搜索,java爬虫(httpclient)和htmlpaser做更多的了解。

Ⅸ java如何读取文件夹中的图片并在界面显示

下面给你提供一个实现,该实现采用了代理模式。这个实现包含两个文件,分别是Client.java和ImageIcoProxy.java,ImageIcoProxy.java负责了图片的延迟加载,你可以修改为不延迟即可。

Client.java的代码为:
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.Icon;
import javax.swing.JFrame;

public class Client extends JFrame {
private static int IMG_WIDTH = 510;
private static int IMG_HEIGHT = 317;
private Icon imgProxy = null;
public static void main(String[] args) {
Client app = new Client();
app.setVisible(true);
}

public Client() {
super("Virture Proxy Client");
imgProxy = new ImageIcoProxy("D:/test.jpg", IMG_WIDTH, IMG_HEIGHT);
this.setBounds(100, 100, IMG_WIDTH + 10, IMG_HEIGHT + 30);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g) {
super.paint(g);
Insets insets = getInsets();
imgProxy.paintIcon(this, g, insets.left, insets.top);
}
}

ImageIcoProxy.java的代码为:
import java.awt.Component;
import java.awt.Graphics;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;

public class ImageIcoProxy implements Icon {

private ImageIcon realIcon = null;
private String imgName;
private int width;
private int height;
boolean isIconCreated = false;
public ImageIcoProxy(String imgName, int width, int height) {
this.imgName = imgName;
this.width = width;
this.height = height;
}

public int getIconHeight() {
return realIcon.getIconHeight();
}

public int getIconWidth() {
return realIcon.getIconWidth();
}

public void paintIcon(final Component c, Graphics g, int x, int y) {
if (isIconCreated) {
//已经加载了图片,直接显示
realIcon.paintIcon(c, g, x, y);
g.drawString("Just Test", x + 20, y + 370);
} else {
g.drawRect(x, y, width-1, height-1);
g.drawString("Loading photo...", x+20, y+20);
synchronized(this) {
SwingUtilities.invokeLater(new Runnable() {

public void run() {
try {
Thread.currentThread().sleep(2000);
realIcon = new ImageIcon(imgName);
isIconCreated = true;
} catch (Exception e) {
e.printStackTrace();
}
c.repaint();
}

}
);
}
}
}

}

阅读全文

与java中怎么读取图片相关的资料

热点内容
未成年宫野动漫图片 浏览:762
怎么扩大图片储存 浏览:804
小女孩疝气的图片大 浏览:284
如何录照片加图片 浏览:611
word粘贴图片怎样缩小 浏览:63
女生咬嘴唇图片女孩 浏览:288
刮画脸谱图片大全 浏览:164
夹刘海发型图片 浏览:541
word图片浮雕效果 浏览:231
农村男生图片 浏览:325
梁字男生图片 浏览:513
被夸可爱了图片 浏览:99
浪琴男石英表价格图片 浏览:859
鸿蒙系统如何将图片扫描出来 浏览:225
微信图片怎么调整打印 浏览:346
油画棒简单漂亮的图片 浏览:130
九尾的图片高清 浏览:348
染发图片男生中分 浏览:232
高的繁体字怎么写图片 浏览:616
男生万圣节图片动漫 浏览:226