在Java中将字节数组转换为Image对象

问题描述:

我在oracle数据库中有blob数据,我已将其转换为字节数组.

现在,我需要将此字节数组传递给仅接受Image对象的函数.

我想知道如何将字节数组转换为Image.

这是我现在用于转换的代码.

I have blob data in oracle database i have converted it to byte array.

Now i need to pass this byte array to a function which accepts only Image object.

I want to know how to convert the byte array to Image.

This is the code that I''m using for conversion right now.

Blob temp;
Image[] tempImg=new Image[1];
temp = rs.getBlob("FACE");
nt blobLength = (int) temp.length();
byte[] blobbytes = temp.getBytes(1, blobLength);
tempImg[0] = new ImageIcon(blobbytes).getImage();



getBlob是用于从数据库获取blob数据的函数.

任何帮助将不胜感激.
在此先谢谢您.



getBlob is the function to get the blob data form the database.

any help will be appreciated.
Thanks in advance.

您应该这样做:

如何将Byte []转换为Java中的BufferedImage [ ^ ]. BufferedImage是Image的子类型.
You should do it like this:

How To Convert Byte[] To BufferedImage In Java[^]. BufferedImage is a subtype of Image.