Help required in sending images to client

I have a java program that take snapshots of my screen at say 10 pics per second now i want these pics to be sent to another computer in the same order....
i tried to achieve this but i am able to send only 1 image i think the first image.......... heres my code ...
Server code..........
import java.awt.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle; 
import java.awt.Robot;  
import java.awt.image.BufferedImage; 
import javax.swing.JFrame;
import java.net.*;
import javax.imageio.*;
import java.util.*;
import java.io.*;
public class VideoServer extends JFrame
      BufferedImage img; 
      Robot robot; 
      Rectangle rect; 
      public static void main(String args[])
       new VideoServer();
      public VideoServer()
      //init components 
       try
           robot = new Robot(); 
           rect = new Rectangle(200,200,300,300); 
     catch (AWTException e)
            e.printStackTrace();
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
       this.setSize(500,500); 
     //  this.setVisible(true);
       takeShots(); 
      private void takeShots()
       try
           ServerSocket s=new ServerSocket(8189);
           Socket incoming=s.accept();
           try
            OutputStream os=incoming.getOutputStream();
            for (int i = 0;i<100 ; i++)
                img = robot.createScreenCapture(rect); 
            //repaint();
                ImageIO.write(img,"jpg",os);
                if(img==null)
                 System.out.println("NULL");
                try
                 Thread.sleep(50);
                catch (InterruptedException e)
                 e.printStackTrace();
           finally
            s.close();
       catch(IOException e1)
    /*  public void paintComponent(Graphics g)
       super.paintComponents(g);
       //Graphics2D g2 = (Graphics2D)g;
       //g2.drawImage(img,0,0,this);
}and heres my client program
import java.util.*;
import java.io.*;
import java.net.*;
import java.awt.image.*;
import javax.imageio.*;
public class ImageClient
    public static void main(String args[])
       ArrayList list=new ArrayList(100);
       BufferedImage tmp=new BufferedImage(400,400,BufferedImage.TYPE_INT_RGB);
     try
         Socket s=new Socket("127.0.0.1",8189);
         try
          InputStream in=s.getInputStream();
          for(int i=0;i<100;i++)
              tmp=ImageIO.read(in);
              list.add(tmp);
         finally
          s.close();
     catch(IOException e)
         e.printStackTrace();
     try
         for(int i=0;i<100;i++)
          tmp=(BufferedImage)list.get(i);
          ImageIO.write(tmp,"jpg",new File("/home/gaurav/java programs/Formedimages/created"+i+".jpg"));
     catch(Exception exp)
         System.out.println("hello5");
}

It's been a while, but I know you can write a series of images to a file, then later read back that series of images. Why don't you work on doing this with file i/o first (easier to debug, and you can examine the file with standard image viewers), before sprinkling sockets on it?

Similar Messages

  • Help! Urgent help required for adjusting image

    Hi - hoping someone can help.
    I sent the attached PDF -  http://www.sensecreative.co.uk/custUploads/SENSE-36-7977-95928/77317/SENSE-36-7977-95928-7 7317-2440.zip - to print with Sense Creative. The cards were printed and they've turned out quite visibly green on the reverse (where it should be white).
    I've printed the artwork on several printers I have access to and it looks as it should, however SC are saying that the issue is with the artwork
    "The green tinge you see on the reverse of these cards is prevalent in the artwork. The makeup of the background is approximately c-15 m-11 y-15 k-0. the predominant levels of the yellow and cyan will give you the green tint. Upping the levels of the artwork in or substituting the cyan, magenta and yellow levels with more black in Photoshop will likely give you the result you require. We are satisfied that in both instances, the artwork has printed correctly and the colours are well within tolerance given the nature of the artwork."
    So, I'm in a bit of a pickle as the cards are needed for an event next week.
    How do I change the image levels? Or are they talking nonsense and trying to pass the buck?
    Help!

    station_two,
    Acrobat View> Tools> Print Production> Output Preview: Object Inspector will call out the objects' profiles if you click on each one individually (in this case all appeaar to be "Device CMYK" or Untagged CMYK)
    untagged CMYK has the same pitfalls as untagged RGB... if one applys or assumes the wrong SOURCE PROFILE it doesn't CONVERT colors to Monitor RGB or Print Space correctly

  • Help required with ADFS 3.0 client certificate authentication

    Hi,
    I am currently working on integrating ADFS 3.o for Single Sign On to some 3rd party services along with PKI solution. The basic requirement is that I should be able to choose client authentication certificate as an authentication method in ADFS and then
    federate user credentials to 3rd party trust for single-sign-on.
    I had done this successfully with ADFS 2.0 and that setup is working fine. I have the setup as ADFS 3.0 client authentication method enabled. When I open browser to logon, the ADFS 3.0 page displays a message as "Select a certificate that you want to
    use for authentication. If you cancel the operation, please close your browser and try again." but the certificates are not displayed for selection.
    The certificates are valid and have valid chaining to CA. Could someone help me resolve this issue?
    Thanks!
    -Chinmaya Karve

    Hi Yan,
    Thanks for your response. I have gone through the posts that you have suggested, and my setup looks pretty much as expected.
    So, as I mentioned earlier, I have 2 parallel setups with 3rd party service(SalesForce). Once of them is running ADFS 2.0 and another one has ADFS 3.0. I can logon to the third-party services, from both the setups using username/format. I can logon to SF
    using client authentication certificate from ADFS 2.0 setup, but from the same client machine, when I try to logon SF via ADFS 3.0, the browser just does not pick up any certificate. The page just shows message of "Select a certificate that you want to use
    for authentication. If you cancel the operation, please close your browser and try again.".
    I have checked the browser, and it has the right certificates. Also, the same browser/machine is used to logon to SF through ADFS 2.0 via client certificate, which works just fine !
    I am really confused now, as to whose issue this really is...
    Just to confirm, I am using Certificate Authentication from ADFS 3.0 Authentication Methods for both Intranet and Extranet.
    Any suggestion or inputs where I could have gone wrong in the setup?
    Thanks!

  • Help required for Sender Proxy/RFC and Receiver RFC approach. Urgent please

    Hi All,
    I have one sender R/3 system
    I have two receivers R/3 systems
    Business Partners data from sender R/3 system needs to be repliacted to 2 receivers R/3 systems
    From sender R/3 system one Sync Abap Client Proxy or
    Sync RFC will send Business Partners data to XI.
    For both receivers R/3 systems there is only one RFC Currently there is no flag condition for 2 receivers as this is
    Business Partner replication scenario.
    Also In XI there is restriction that multiple sync receivers cannot be there.
    Please let me know how to make this approach.
    Regards

    Rich,
    Create two O/B Interfaces - Synch. Create Proxy1 for O/B Interface1 , Proxy2 for O/B interface 2.
    So while defining Receiver determinatio, you will define as following,
    Receiver Determination----1
    Sender : Sender_BusinessSystem
    Sender Interface : O/B Interface 1 ( i.e Proxy1)
    Receiver : BusinessSystem_ C
    Interace Determination
    Sender : Sender_BusinessSystem
    Sender Interface : O/B Interface 1 ( i.e Proxy1)
    Inbound Interface: RFC_Rec
    Receiver Determination----2
    Sender : Sender_BusinessSystem
    Sender Interface : O/B Interface 2 ( i.e Proxy2)
    Receiver : BusinessSystem_D
    Interace Determination
    Sender : Sender_BusinessSystem
    Sender Interface : O/B Interface 2 ( i.e Proxy2)
    Inbound Interface: RFC_Rec
    Hope it helps!
    raj.

  • Help required in sending automated mails to hr-coordinator

    Dear Friends,
    I have a requirement where to send the mails to HR co-ordinator via r3-program
    suggestions are appreciated, Help me in this regard.
    Thanks in advance.
    Regards,
    nallani.

    Hi Nallani,
    Write a <Zprogram>, use your own logic in the program to send mails.
    Example: Suppose mails should be generated to the respective administrators when a employee is hired.
    clue - once IT 0001 is saved you should generate a mails.
    Solution: My logic is, check Personnel area & Personnel sub-area, based  on this in IT 0001 - pick up respective Administrator for that employee, and run the program to send mails.
    for this you need to maintain Dynamic actions for IT 0001, there you need to  maintain your <Zprogram>, while change/create of IT 0001, <Zprogram> should be executed
    [Insure the respective administrators maintained with their e-mail id addresses]
    Hope you got an idea how to make a show for your query?
    Cheers,
    TG

  • Help required regarding sending jar files using bluetooth

    I want to send jar file from Nokia 7610 (S60), or any other phone for that matter, to any other phone using bluetooth. The problem is that, when I look at the options available for the jar file (which is saved in the Inbox), the send option is not visible.
    I looked at the previous postings on this topic. Is it due to "Closed Content List" (CCL)??? What are the possible workarounds, other than using getResourceAsStream or some software like FExplorer???
    Also, this problem is not encountered in Sony Ericsson phones. Plz help regarding the same...

    Hi,
    You might wanna look take a look in the JSR 82 Specifications. There is a method like agent.startInquiry(); that starts a search for nearby BT devices. All you have to do is place each found device in an array of type Vector.
    It would have been easier if your code or a snippet of it was available to see what the problem was.
    Rambo.
    PS: A client application application starts a connection on a server application. Where you put them is up to you.

  • Help required with an image

    Hi all,
    I wonder if someone can help me with the following issue.
    If you see the attached image in the top left hand corner their is a square box which is a different shade to the rest of the header.
    I need to rectify this and blend it in with the rest on the header colour; however, I do not know how to do this and would appreciate some assistance in doing this.
    I'm a noobie to photoshop so any help is much appreciated.

    It seems you've copied another portion of the texture to overlay something you didn't want seen...
    As opposed to copy/paste of a rectangular region, this is almost a textbook use for Content Aware Fill, which should (assuming it works properly) match the pattern and blend the colors.
    Try selecting just the blemish or whatever you're trying to cover, then expand the selection a few pixels, then Edit - Fill - Content Aware.
    -Noel

  • Sending image in mail

    Hi,
    I have a requirement to send image in mail.
    I got a code from a post which is as following :
    import javax.mail.* ;
    import javax.mail.internet.* ;
    import java.util.Properties;
    class SimpleMail1 {
        public static void main(String[] args) throws Exception{
            System.out.println("Sending mail...");
            Properties props = new Properties();
            props.setProperty("mail.transport.protocol", "smtp");
            props.setProperty("mail.host", "smtp.mymailserver.com");
            props.setProperty("mail.user", "myuser");
            props.setProperty("mail.password", "mypwd");
    Session mailSession = Session.getDefaultInstance(props, null);
            mailSession.setDebug(true);
            Transport transport = mailSession.getTransport();
    MimeMessage message = new MimeMessage(mailSession);
            message.setSubject("HTML  mail with images");
    // write sender's and recpient's email address
       message.setContent
              (" img src=image_path" + "html/text");;    
            transport.connect();
            transport.sendMessage(message,
                message.getRecipients(Message.RecipientType.TO));
            transport.close();
    Here, the image is being taken from an internet link whereas I am working on Linux server.
    If I place a file on some location on the server, how to get the file from this location in this code?
    Regards,
    Nikhil

    Cary,
    I got your email overnight.
    The 5 attachments are full size JPEG files, and the overall size of the message is 4.5 MB. Three of them have been compressed more than the other two, which you can see looking at the file sizes shown in the attached screenshot I sent back to you, but all of them decompress into full size photos of good size.
    You may have muddied the water slightly, by Forwarding rather than sending a new message as you did originally. That can easily be checked if you open the message as originally sent, click on Message in the menubar and choose Send Again -- then change the To address to mine.
    However, I think there is another issue causing the message to be sent in Rich Text Format, which causes some conversion of text to HTML, which then is problematic to some email clients some recipients use on Windows computers, notably Outlook and Outlook Express. Specifically, the file name of each photo appearing beneath and between each attachment can cause this, as could multiple fonts (but you did have that). To stop the file name printing, which is coming from iPhoto's preparation of the message, change the selection in the Email dialogue in iPhoto to deselect Include Title and Include Comments.
    Then be sure to send all such messages in Plain Text, and be sure to use Windows Friendly if not already.
    Ernie

  • Urgent help:send image over network using rmi

    hi all,
    i have few question about send image using rmi.
    1) should i use ByteArrayOutputStream to convert image into byte array before i send over network or just use fileinputstream to convert image into byte array like what i have done as below?
    public class RemoteServerImpl  extends UnicastRemoteObject implements RemoteServer
      public RemoteServerImpl() throws RemoteException
      public byte[] getimage() throws RemoteException
        try{
           // capture the whole screen
           BufferedImage screencapture = new Robot().createScreenCapture(new     Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
           // Save as JPEG
           File file = new File("screencapture.jpg");
           ImageIO.write(screencapture, "jpg", file);
            byte[] fileByteContent = null;
           fileByteContent = getImageStream("screencapture.jpg");
           return fileByteContent;
        catch(IOException ex)
      public byte[] getImageStream(String fname) // local method
        String fileName = fname;
        FileInputStream fileInputStream = null;
        byte[] fileByteContent = null;
          try
            int count = 0;
            fileInputStream = new FileInputStream(fileName);  // Obtains input bytes from a file.
            fileByteContent = new byte[fileInputStream.available()]; // Assign size to byte array.
            while (fileInputStream.available()>0)   // Correcting file content bytes, and put them into the byte array.
               fileByteContent[count]=(byte)fileInputStream.read();
               count++;
           catch (IOException fnfe)
         return fileByteContent;           
    }2)if what i done is wrong,can somebody give me guide?else if correct ,then how can i rebuild the image from the byte array and put it in a JLable?i now must use FileOuputStream but how?can anyone answer me or simple code?
    thanks in advance..

    Hi! well a had the same problem sending an image trough RMI.. To solve this i just read the image file into a byte Array and send the array to the client, and then the client creates an imegeIcon from the byte Array containing the image.. Below is the example function ton read the file to a byte Array (on the server) and the function to convert it to a an imageIcon (on the client).
    //      Returns the contents of the file in a byte array.
        public static byte[] getBytesFromFile(File file) throws IOException {
            InputStream is = new FileInputStream(file);
            // Get the size of the file
            long length = file.length();
            // You cannot create an array using a long type.
            // It needs to be an int type.
            // Before converting to an int type, check
            // to ensure that file is not larger than Integer.MAX_VALUE.
            if (length > Integer.MAX_VALUE) {
                // File is too large
            // Create the byte array to hold the data
            byte[] bytes = new byte[(int)length];
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length
                   && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            // Ensure all the bytes have been read in
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file.getName());
            // Close the input stream and return bytes
            is.close();
            return bytes;
        }to use this function simply use something like this
    public byte[] getImage(){
    byte[] imageData;
              File file = new File("pic.jpg");
              // Change pic.jpg for the name of your file (duh)
              try{
                   imageData = getBytesFromFile(file);
                   // Send to client via RMI
                            return imageData;
              }catch(IOException ioe){
                           // Handle exception
                           return null; // or whatever you want..
    }and then on the client you could call a function like this
    public ImageIcon getImageFromServer(){
         try{
              // get the image from the RMI server
              byte[] imgBytes = myServerObject.getImage();
              // Create an imageIcon from the Array of bytes
              ImageIcon ii = new ImageIcon(imgBytes);
              return ii;
         }catch(Exception e){
              // Handle some error..
              // If yo get here probably something went wrong with the server
              // like File Not Found or something like that..
              e.printStackTrace();
              return null;
    }Hope it helps you..

  • Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Try this -> http://support.apple.com/kb/TA38632?viewlocale=en_US

  • Sending thumbnail of images to client on request using servlet/jsp

    hi
    can anybody tell me how can we send thumbnail of more than one image to client using servlet or jsp just the way we thumbnail of images in google

    Then create a servlet which uses Java 2D API to rezise the image and writes it to the outputstream of the response. Call that servlet in the <img> tag along with an unique request parameter identifying the image.

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Help required in configuring multicast routing

    Hi,
    We have two 2 servers and 200 clients.
    2 servers are in one vlan, 200 clients are in another vlan.
    first server will send data to second server with multicast address 234.5.6.7
    second server will send data to 200 clients with multicast address 234.5.6.8
    first server is able to send data to second server.
    but second server is not able to send data to clients.
    If we put clients in same vlan, second server is able to send data to clients.
    So we understood that multicast routing needs to be enabled in L3 switch.
    Switch Model: 3550
    IOS version: 12.1(19)EA1a
    Any help in configuration required for this.........
    Regards
    SKRAO

    Hi Skrao,
    Does your client vlan and server vlan exist on same layer 3 switch if yes then perform this config and it should work..
    On global config mode
    ip multicast-routing distributed
    On interface vlan config (for both client vlan and server vlan)
    ip pim sparse-dense-mode
    You can very well fine tune later.Try this and update if it worked.
    HTH
    Ankur

  • How to send images using SOAP adapter

    hi All,
    I want to send images using the SOAP adapter . ( Sender and Receiver )
    Can anybody help out with this requirement
    Regards,
    Loveena

    Hi,
    Following links may help U
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
    to know the basics about soap adapter u cn check out this link
    /people/padmankumar.sahoo/blog/2005/02/15/an-overview-of-soap
    to get in detail about the attachments chk out this link
    hi i am unable to attach an attachment in File to mail scenario
    Regards
    Pullarao

  • SAP MM Functional Specs -Help Required

    Gurus , I am newly taking assignment for SAP MM functional .I request any one from this forum to help me in sending a sample Functional spec for SAP MM /SAP MM customization .It will be a great help for me as I am new in this area and just got trained
    Pl send your links or sample functiona spec to
    [email protected]

    Hi James,,,
    Functional Specs differs from client to client how they use it. Anyways from ur client u can take the specs it shd be in the Process Database.
    In general the Spec has the following info ....
    1. Process Owner.
    2. Requested by :
    3. SAP MM consultant incharge( Ur Name )
    4. Abaper, If required.
    5. Integration Team Members.
    6. AS- IS & TO- BE
    7. If any User exits or enhancements needed then mentiion in details.
        Insense the config & Tech part need to be developed shd be mentioned clearly.
    Regards
    Balaji

Maybe you are looking for

  • Volumes folder on my xserve raid

    Hey all! When my network users login, they can see the root level of my xserve raid. Shouldn't this ve hidden? What if someone decides to trash my Volumes folder or decides to make any folder they want? When I try to disable sharing on the root level

  • Condition types for Import Vendor not getting in Contract

    Hi, In Contract Document if Import Vendor selected, for the Line items we are not getting the Import Pricing Condition types. Instead, we are getting the Local pricing condition types even if Import vendor schema maintained in Vendor Master. We have

  • Inadequate sound capture levels using Audigy 2 w/ Ubuntu Linux.

    Hello, everything works fine in Windows XP. I use Audacity to do some basic multitrack recording with my guitar and Line6 POD. However, I recently installed Ubuntu Linux (5.10) in a dual boot configuration with Windows. I cannot get decent recording

  • EHS : Creating new report parameter/ symbol for MSDS cover sheet

    Hi, I am working on the SAP EHS module. I have a requirement in which I need to have the country name (description) on the MSDS cover sheet instaed of the country key which is presently coming in there. As per the standard settings, the report parame

  • Embed video into iweb page

    Is there any way to embed video into my iWeb page without making an external HTML file? Thanks.