creating Image from byte array
807569Sep 27 2006 — edited Sep 28 2006Hi,
i am facing a problem while i am creating a image from byte array.
this code i am using
public class ImageTest extends JFrame{
byte[] test1={
(byte)0x7E,(byte)0xB5,(byte)0xB8,(byte)0x5A,(byte)0X1,(byte)0X5E,(byte)0X5,(byte)0X24,(byte)0XE,(byte)0X0E,(byte)0X1C,(byte)0X7A,(byte)0XBC,(byte)0X71,(byte)0XC7,(byte)0X38,(byte)0X00,(byte)0X71,(byte)0XCE,(byte)0X00,(byte)0X3C,(byte)0X3F,(byte)0XF0,(byte)0X5E,(byte)0X5,(byte)0X25,
(byte)0X1,(byte)0X5E,(byte)0X5,(byte)0X24,(byte)0XE,(byte)0X0E,(byte)0X1C,(byte)0X7F,(byte)0XFC,(byte)0X71,(byte)0XC7,(byte)0X3F,(byte)0XE0,(byte)0X3F,(byte)0X8F,(byte)0XF0,(byte)0X3C,(byte)0X70,(byte)0X38,(byte)0X5E,(byte)0X5,(byte)0X25,
(byte)0X1,(byte)0X5E,(byte)0X5,(byte)0X24,(byte)0XE,(byte)0X0E,(byte)0X1C,(byte)0XFF,(byte)0XFC,(byte)0X70,(byte)0X87,(byte)0X3F,(byte)0XE0,(byte)0X1F,(byte)0X0F,(byte)0XF0,(byte)0X3C,(byte)0X70,(byte)0X38,(byte)0X5E,(byte)0X5,(byte)0X25,
(byte)0X1,(byte)0X5E,(byte)0X6,(byte)0X24,(byte)0X2,(byte)0X01,(byte)0XC0,(byte)0X5E,(byte)0X10,(byte)0X25,
(byte)0X1,(byte)0X5E,(byte)0X6,(byte)0X24,(byte)0X2,(byte)0X01,(byte)0X80,(byte)0X5E,(byte)0X10,(byte)0X25,
(byte)0X1,(byte)0X5E,(byte)0X18,(byte)0X25,(byte)0x04,(byte)0x8
};
public ImageTest()
{
Image returnValue = null;
try
{
returnValue = Toolkit.getDefaultToolkit().createImage(
test1,10,100);
JLabel testl=new JLabel();
getContentPane().add(testl);
ImageIcon icon=new ImageIcon(returnValue);
icon.setImage(returnValue);
testl.setIcon(icon);
System.out.println("image is"+returnValue);
} catch (Exception e) {
System.err.println("Error loading: " +e);
}
}
public static void main(String args[])
{
ImageTest test=new ImageTest();
test.setSize(300,300);
test.setVisible(true);
}
}
here image object is careating but it is not displaying on the frame.anybody please help me to solve this problem...
thanks in advance
pradeep