P
papachris79
Hello to everyone!!
I'm working on a program that downloads photos (jpeg) from a server's
camera and that will show each photo on a frame as soon as it's
downloaded. Kinda like a motion jpeg (mjpeg).
I've managed to get the photos but i'm having trouble displaying them.
Can someone please show me how i can do this?
This is pretty much how my program looks like....
******************************************************************************
byte [] hostIP = {...};
InetAddress hostAddress = InetAddress.getByAddress(hostIP);
byte [] rxbuffer = new byte[1024];
DatagramSocket r = new DatagramSocket(clientPort);
DatagramPacket q = new DatagramPacket(rxbuffer,rxbuffer.length);
byte [] txbuffer = imageInfo.getBytes();
DatagramSocket s = new DatagramSocket();
DatagramPacket p = new DatagramPacket
(txbuffer,txbuffer.length,hostAddress,serverPort);
r.setSoTimeout(200);
newPhoto:
for (int j = 0; j<10; j++) {
File ImageFile = new File("Image"+String.valueOf(j+1)+".jpeg");
FileOutputStream Image = new FileOutputStream(ImageFile);
s.send(p);
for(;{
try {
r.receive(q);
Image.write(rxbuffer,0,q.getLength());
} catch (Exception x1) {continue newPhoto;}
}
}
************************************************************************************
Thanks
Christos Papageorgiou
I'm working on a program that downloads photos (jpeg) from a server's
camera and that will show each photo on a frame as soon as it's
downloaded. Kinda like a motion jpeg (mjpeg).
I've managed to get the photos but i'm having trouble displaying them.
with the frame and last DrawImage will draw the images on the frame.From what i understand, i must create a JFrame, then a JPanel to work
Can someone please show me how i can do this?
This is pretty much how my program looks like....
******************************************************************************
byte [] hostIP = {...};
InetAddress hostAddress = InetAddress.getByAddress(hostIP);
byte [] rxbuffer = new byte[1024];
DatagramSocket r = new DatagramSocket(clientPort);
DatagramPacket q = new DatagramPacket(rxbuffer,rxbuffer.length);
byte [] txbuffer = imageInfo.getBytes();
DatagramSocket s = new DatagramSocket();
DatagramPacket p = new DatagramPacket
(txbuffer,txbuffer.length,hostAddress,serverPort);
r.setSoTimeout(200);
newPhoto:
for (int j = 0; j<10; j++) {
File ImageFile = new File("Image"+String.valueOf(j+1)+".jpeg");
FileOutputStream Image = new FileOutputStream(ImageFile);
s.send(p);
for(;{
try {
r.receive(q);
Image.write(rxbuffer,0,q.getLength());
} catch (Exception x1) {continue newPhoto;}
}
}
************************************************************************************
Thanks
Christos Papageorgiou