【发布时间】:2014-07-25 04:01:20
【问题描述】:
如何从 javafx image/imageview 类中获取 byte[]?我想将我的图像作为 Blob 存储到我的数据库中。这是我使用的方法
public PreparedStatement prepareQuery(HSQLDBConnector connector) {
try {
Blob logoBlob = connector.connection.createBlob();
logoBlob.setBytes(0,logo.getImage());//stuck here
for (int i = 0, a = 1; i < data.length; i++, a++) {
connector.prepStatCreateProfile.setString(a, data[i]);
}
//store LOB
connector.prepStatCreateProfile.setBlob(11, logoBlob);
} catch (SQLException ex) {
ex.printStackTrace();
}
return connector.prepStatCreateProfile;
}
有没有办法将我当前的对象 (imageview),image) 转换为 byte[]?,或者我应该开始考虑为我的图像使用其他类/或者通过引用指向该位置使用路径/网址?
【问题讨论】:
标签: java image javafx byte processing