I have image file that are stored in the database. I need to retrieve the image from the database and load it as Texture2D. I tried the following code and it does not work.
// Get the image from the database as in ObjectInputStream
public static ObjectInputStream getXithImageIcon(ResultSet rs, String ColumnName) throws SQLException, IOException, ClassNotFoundException {
ObjectInputStream ois = null;
Blob blob;
blob = rs.getBlob(ColumnName);
if (blob != null) {
System.out.println( "blob Size = " + blob.length() );
ois = new ObjectInputStream(blob.getBinaryStream());
blob.free();
}
// return loader.data[0];
return ois;
}
// normalImage , hoveredImage , pressImage are the ObjectInputStream being loaded from the database.
try {
TextureLoader loader = TextureLoader.getInstance();
if (normalImage != null) {
NORMAL_IMAGE = loader.loadTexture(normalImage, FlipMode.NOT_FLIPPED, TextureFormat.RGBA, MipmapMode.BASE_LEVEL, true);
normalImage.close();
}
if (hoveredImage != null) {
HOVERED_IMAGE = loader.loadTexture(hoveredImage, FlipMode.NOT_FLIPPED, TextureFormat.RGBA, MipmapMode.BASE_LEVEL, true);
hoveredImage.close();
}
if (pressImage != null) {
PRESS_IMAGE = loader.loadTexture(pressImage, FlipMode.NOT_FLIPPED, TextureFormat.RGBA, MipmapMode.BASE_LEVEL, true);
pressImage.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I'm getting a Square 2X2 black and white image. Can anybody help me on this ?