我如何从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;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法从我当前的对象(imageview),图像转换为byte [] ?,或者shoud我开始考虑使用其他类作为我的图像/或者指向参考位置并使用路径/网址?