Sending an Image

Hello!
Usually, when I use networking (which is rare) PrintWriter fulfills my needs. But in this case I need to send a BufferedImage over a network, and I don't think PrintWriter would work. Does somebody know what class I could use?
Thanks!

I realize this. Here's the pseudo code of what I'm trying to accomplish:
1. Get the image to be sent.
2. Get the data as an array of bytes.
3. Use BufferedOutputStream to send the bytes.
The problem with my code is with #2. I can't seem to find a way to convert an image into an array of bytes. The above code is the closest I have ever gotten.
Any suggestions?
here my suggestion
1. get image from file or what?, if you want to get image from file then you should use fileInputStream like this :
public byte[] readFile(String fileName){
       ByteArrayOutputStream bos = new ByteArrayOutputStream();                   
        try{
            fis = new FileInputStream(sourceFile);
            int d;
            while((d=fis.read())!=-1){
               bos.write(d);               
            System.out.println("LOAD FILE COMPLETED");
        }catch (IOException e){
        //nothing to do
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("BLA2");
        return bos.toByteArray();
   }2. then you can send bos that already come byteArray like this :
public void sendChunkFile(byte[] fileByte) {
        DataOutputStream os;
        int off = 0;
        boolean endFile = false;
        while (!endFile) {
            if ((off+chunkSize)>=fileSize) {
                endFile = true;
                chunkSize = fileSize - off;
                os.write(fileByte,off,chunkSize);
                off = off + chunkSize;    
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
        if (endFile){
            System.out.println("FILE Sent");
            chunkSize = CHUNK_SIZE;
   }maybe that will help you
Edited by: nDeh-tEa on Oct 6, 2007 4:38 PM

Similar Messages

  • Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    I only use Image Capture, so I can't speak for other software.
    Here is how I select a Scan To destination:
    If you are using the minimal details screen, you should have the same submenu to the left of the page size.

  • Not able to see the output in sost when sending the image in email body

    I am sending the image in email body and when m trying to see the output in SOST then it showing a page 'you are not connected to the internet'
    I am able to see the output when m saving local objects but when m saving it in some package its showing me this page
    Kindly help it
    Regards
    Pratham Kapoor

    Hello Prakash,
    Thanks for the reply
    I am able to see the mail in SOST but when I click on the Display Document to see the content of the mail then I am getting this error of 'you are not connected to the internet'
    My Program is to put the logo in my email body
    I am sending you the attached image

  • How can I send an image directly from the browser as an attachment, not a link?

    I'm wondering if there's a way-- either via some kind of add-on or a direct FF customization-- to send an image as an attachment rather than as a link? either right-clicking an image and selecting "send image" or dragging an image into a "new message" window in outlook for example merely adds a link to the image and I'd rather that the image itself was added as an attachment. this functionality is available in IE as "email picture," which is extremely useful.
    thanks for any insight here.

    It was not mentioned what the client is. If it is a browser, the image can be sent using hml img tag. If it is using streams, then u need to set content type to image/gif or image/jpg ( depending the image u r sending) using response obj.
    response.setContentType("image/gif");
    Bye...

  • In Applet  how to send an ' image' and 'string' as parameter

    Hi,
    In web application, how to use post method in applet to send an ' image' and 'string' as a parameter, I can able to send the image alone form applet to servlet.

    869665 wrote:
    Hi,
    In web application, how to use post method in applet to send an ' image' and 'string' as a parameter, I can able to send the image alone form applet to servlet.One way to do this is to convert your binary image data to base64 (convert it to plain text) and send it along with your other String parameter, delimited with a & of course.
    Edited by: maheshguruswamy on Aug 2, 2011 11:59 AM

  • TS3276 Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Apple Mail isn't going to change the format of any of your attachments. it isn't going to corrupt them either.
    Exchange is a transport protocol and server. The issue you describe is not related to Exchange.
    There are many different versions of Microsoft Outlook in use and they all have e-mail bugs. Different versions have different bugs. Some Apple Mail hack to get around a bug in Outlook 2003 may cause the same message to be problematic in Outlook 2000. Fix them both and another issue will cause trouble in Outlook 2007. You can't fix this. Apple can't fix this. Microsoft can and has but that is irrelevant if your recipients are using older versions.
    One specific problem is that Apple Mail always sends image attachments inline, as images, not as iconized files. You can change this with Attachment Tamer. Just be aware that use of this software will break other things such as Stationery. E-mail is just a disaster. To date, no one outside of Apple has ever implemented the e-mail standards from 1993. Apple has continually changed its e-mail software to be more compatible with the de-facto standards that Netscape and Microsoft have unilaterally defined and people documented as "standards" after the fact. The e-mail messages that Apple Mail sends are 100% correct and do not violate any of the original standards from 1993 or the Microsoft/Netscape modifications. The problem is entirely bugs and limitations in various versions of Outlook.

  • How to stop Mail from searching for sender's image?

    When I'm going through messages in Mail, it won't display the message in the preview pane for several seconds until it completes the "Searching for sender's image" process. I have a large address book with several thousand entries. Is there a way to prevent Mail from searching for the contact's image in the Address Book? This wasn't an issue in 10.4.11.
    Here's a screenshot:
    http://img55.imageshack.us/img55/6007/001rz6.jpg

    The iPhone data plans are unlimited, so you shouldnt be concerned about cost. That being said, it is ANNOYING to have all accounts (I have six) check email just because I launch the mail app. And if I follow a URL in an email to Safari, then come back to Mail, it checks AGAIN.
    Nope, there is not way to stop if from doing that short of turning the account OFF under Mail Settings, which is even MORE inconvenient. I went to http://www.apple.com/feedback/iphone.html and left them a message. Perhaps you should do the same.

  • How to send a image or bmp file through SMS

    Hai All,
    My requirement is that,I have to send a image(company logo) with my text message.Now problem is that I am using XML API .means I am Converting that image into hexa code and sending that by encoding according to my service providers specifications.but they didn't provide what should be the UDH format and format of image data.So please help me in this as I am stucking here for about a month.Any Suggestions will be appreciated.
    Thanks & Regards:
    SEVish

    Hi Atul,
    when i am converting my image into hexacode then it fits in three sms ,So sms can be multiple but it should be reassembled when it reaches to the client's device. My service provider told me to use XML API to send sms through my application and yes I am using HTTPPOST method .I am sending a piece of code please give me some suggestions after analyzing it.
    Thanks in Advance
    SEVish
    public static void ImageTransmission(String ot) throws HttpException, IOException{
              String smsSchema          =     null;
              String mobileNos           =      "919857555992";
    String str10                = "%30%00%00%04%54%65%73%74%02%01%00%00%48%1c%01%66%66%66%66%66%66%66%66%66%99%99%99%99%99%99%99%99%99%80%00%00%00%00%00%00%00%01%40%00%00%00%60%00%E0%00%02%40%00%00%0E%90%03%10%00%02%80%00%00%31%08%0C%F3%B8%01%80%00%00%40%04%11%04%44%01%40%00%00%FF%FE%2F%8B%12%02%40%00%00%00%00%53%8C%AA%02%80%00%00%00%00%62%89%C4%01%80%00%00%00%00%41%41%40%01%40%00%00%00%00%01%42%80%02%40%00%20%00%00";
    String str20                = "%01%42%80%02%80%01%F0%00%00%00%A2%80%01%80%0F%FE%00%00%00%A5%00%01%5F%FF%FF%FF%FF%FE%A5%7F%FA%40%0A%AA%00%00%00%55%00%02%82%01%50%04%40%01%5D%08%A1%88%10%24%80%00%40%FF%02%01%40%41%00%01%00%03%AB%E0%02%44%00%00%08%20%0D%55%58%82%80%10%14%40%00%1A%AA%AC%01%80%00%00%00%00%35%55%56%01%40%01%00%00%80%6A%AA%AB%02%40%00%00%00%00%55%55%55%02%80%00%00%00%00%00%00%00%01%99%99%99%99%99%99%99";
    String str30                = "%99%99%66%66%66%66%66%66%66%66%66";
    HttpClient client           =     null;
              PostMethod httppost     =      null;
              String encodedMsg          =     null;
              String[] smstohex           =      new String[10];
              String     responseString      =     null;
              String[] sms                =      new String[10];
              VSFEncoder vsf           =      new VSFEncoder();
    /* XML format for sending SMS */
              sms[0] ="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+
         "<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >"+
              "<MESSAGE VER=\"1.2\">"+"<USER USERNAME=\""+"XYZ"+"\" PASSWORD=\""+"XYZ"+"\"/>"+
              "<SMS UDH=\"1\" CODING=\"1\" TEXT=\""+ ot +"\" PROPERTY=\"0\" ID=\"1\">"+
         "<ADDRESS FROM=\"Flexware\" TO=\"" +mobileNos+"\" SEQ=\"1\"/>"+
              "</SMS></MESSAGE>";
              sms[1] ="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+
         "<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >"+
              "<MESSAGE VER=\"1.2\">"+"<USER USERNAME=\""+"XYZ"+"\" PASSWORD=\""+"XYZ"+"\"/>"+
              "<SMS UDH=\"2\" CODING=\"1\" TEXT=\""+ot+"\" PROPERTY=\"0\" ID=\"2\">"+
         "<ADDRESS FROM=\"Flexware\" TO=\"" +mobileNos+"\" SEQ=\"2\"/>"+
              "</SMS></MESSAGE>";
              sms[2] ="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+
         "<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >"+
              "<MESSAGE VER=\"1.2\">"+"<USER USERNAME=\""+"XYZ"+"\" PASSWORD=\""+"XYZ"+"\"/>"+
              "<SMS UDH=\"3\" CODING=\"1\" TEXT=\""+ot+"\" PROPERTY=\"0\" ID=\"3\">"+
         "<ADDRESS FROM=\"Flexware\" TO=\"" +mobileNos+"\" SEQ=\"3\"/>"+
              "</SMS></MESSAGE>";
              for(int i =0 ;i<3;i++){
              encodedMsg = vsf.encodeSMS(sms);
              client      =      new HttpClient();
              httppost      =      new PostMethod("Some URL"+encodedMsg+"&action=send");
              client.executeMethod(httppost);
              if (httppost.getStatusCode() == HttpStatus.SC_OK)
              responseString = httppost.getResponseBodyAsString();
                   System.out.println("responseString : " + responseString);
                   //logger.info("SMS Sent Status : "+httppost.getStatusLine().toString());
         }else
                        System.out.println("Unexpected failure: " + httppost.getStatusLine().toString());
                        //logger.info("SMS Sent Status<><><> "+httppost.getStatusLine().toString());
              httppost.releaseConnection();

  • Sending an Image file via UART

    Hi All,
    1. Is it possible to send an image file( .jpg -1080p) from PC to FPGA(ML605 evaluation board) via UART ?
    2. .jpg to .hex to .txt then  through hyper terminal ? or any  other way ?
    Meganadhan
     

    thanks ignacio
    i will try it letter
    but for sending an image to fpga, can i use realterm?  actually i'm doing image encryption project and the size pixel is 1600X1600, it's very big , but it's ok if it will take a long time for transfer it via UART because i just want to make sure that my alghorithm was true.
     and i have some trouble with the uart rx code. i would like to simulate it with random bit that represent transfer bit from pc, but it's hard to sychronise the timing between uart rx and the random bit program , here the code
    RANDOM BIT
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    entity random is
    generic (
    g_CLKS_PER_BIT : integer := 87 -- Needs to be set correctly--> 10 MHZ/115200(baud rate)
    Port ( clk :in STD_LOGIC;
    output : out STD_LOGIC);
    end random;
    architecture Behavioral of random is
    signal counter: integer:=0;
    begin
    process (clk)
    begin
    if rising_edge(clk) then
    counter <= counter+1;
    if counter= (g_CLKS_PER_BIT-1) then
    output <= '1';
    elsif counter=55 then
    output <= '0';
    elsif counter=65 then
    output <= '0';
    elsif counter=75 then
    output <= '0';
    elsif counter=85 then
    output <= '1';
    elsif counter=95 then
    output <= '0';
    elsif counter=105 then
    output <= '0';
    elsif counter=115 then
    output <= '0';
    --elsif counter =1 then
    counter <= 0;
    end if;
    end if;
    end process;
    end Behavioral;
    ----------------------------------------------------------------------UART RX
    -- File Downloaded from http://www.nandland.com
    -- This file contains the UART Receiver. This receiver is able to
    -- receive 8 bits of serial data, one start bit, one stop bit,
    -- and no parity bit. When receive is complete o_rx_dv will be
    -- driven high for one clock cycle.
    -- Set Generic g_CLKS_PER_BIT as follows:
    -- g_CLKS_PER_BIT = (Frequency of i_clk)/(Frequency of UART)
    -- Example: 10 MHz Clock, 115200 baud UART
    -- (10000000)/(115200) = 87
    library ieee;
    use ieee.std_logic_1164.ALL;
    use ieee.numeric_std.all;
    entity receive is
    generic (
    g_CLKS_PER_BIT : integer := 87 -- Needs to be set correctly--> 10 MHZ/115200(baud rate)
    port (
    i_clk : in std_logic;
    i_rx_serial : in std_logic;
    o_rx_dv : out std_logic;
    o_rx_byte : out std_logic_vector(7 downto 0)
    end receive;
    architecture rtl of receive is
    type t_SM_MAIN is (s_IDLE, s_RX_START_BIT, s_RX_DATA_BITS,
    s_RX_STOP_BIT, s_CLEANUP);
    signal r_SM_MAIN : t_SM_MAIN := s_IDLE;
    signal r_RX_DATA_R : std_logic := '0';
    signal r_RX_DATA &colon; std_logic := '0';
    signal r_CLK_COUNT : integer range 0 to g_CLKS_PER_BIT-1 := 0;
    signal r_BIT_INDEX : integer range 0 to 7 := 0; -- 8 Bits Total
    signal r_RX_BYTE : std_logic_vector(7 downto 0):= (others => '0');
    signal r_RX_DV : std_logic := '0';
    begin
    -- Purpose: Double-register the incoming data.
    -- This allows it to be used in the UART RX Clock Domain.
    -- (It removes problems caused by metastabiliy)
    p_SAMPLE : process (i_clk)
    begin
    if rising_edge(i_clk) then
    r_RX_DATA_R <= i_rx_serial;
    r_RX_DATA <= r_RX_DATA_R;
    end if;
    end process p_SAMPLE;
    -- Purpose: Control RX state machine
    p_UART_RX : process (i_clk)
    begin
    if rising_edge(i_clk) then
    case r_SM_MAIN is
    when s_IDLE =>
    r_RX_DV <= '0';
    r_CLK_COUNT <= 0;
    r_BIT_INDEX <= 0;
    if r_RX_DATA = '0' then -- Start bit detected
    r_SM_MAIN <= s_RX_START_BIT;
    else
    r_SM_MAIN <= s_IDLE;
    end if;
    -- Check middle of start bit to make sure it's still low
    when s_RX_START_BIT =>
    if r_CLK_COUNT = (g_CLKS_PER_BIT-1)/2 then
    if r_RX_DATA = '0' then
    r_CLK_COUNT <= 0; -- reset counter since we found the middle
    r_SM_MAIN <= s_RX_DATA_BITS;
    else
    r_SM_MAIN <= s_IDLE;
    end if;
    else
    r_CLK_COUNT <= r_CLK_COUNT + 1;
    r_SM_MAIN <= s_RX_START_BIT;
    end if;
    -- Wait g_CLKS_PER_BIT-1 clock cycles to sample serial data
    when s_RX_DATA_BITS =>
    if r_CLK_COUNT < g_CLKS_PER_BIT-1 then
    r_CLK_COUNT <= r_CLK_COUNT + 1;
    r_SM_MAIN <= s_RX_DATA_BITS;
    else
    r_CLK_COUNT <= 0;
    r_RX_BYTE(r_BIT_INDEX) <= r_RX_DATA;
    -- Check if we have sent out all bits
    if r_BIT_INDEX < 7 then
    r_BIT_INDEX <= r_BIT_INDEX + 1;
    r_SM_MAIN <= s_RX_DATA_BITS;
    else
    r_BIT_INDEX <= 0;
    r_SM_MAIN <= s_RX_STOP_BIT;
    end if;
    end if;
    -- Receive Stop bit. Stop bit = 1
    when s_RX_STOP_BIT =>
    -- Wait g_CLKS_PER_BIT-1 clock cycles for Stop bit to finish
    if r_CLK_COUNT < g_CLKS_PER_BIT-1 then
    r_CLK_COUNT <= r_CLK_COUNT + 1;
    r_SM_MAIN <= s_RX_STOP_BIT;
    else
    r_RX_DV <= '1';
    r_CLK_COUNT <= 0;
    r_SM_MAIN <= s_CLEANUP;
    end if;
    -- Stay here 1 clock
    when s_CLEANUP =>
    r_SM_MAIN <= s_IDLE;
    r_RX_DV <= '0';
    when others =>
    r_SM_MAIN <= s_IDLE;
    end case;
    end if;
    end process p_UART_RX;
    o_rx_dv <= r_RX_DV;
    o_rx_byte <= r_RX_BYTE;
    end rtl;
    TOP
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    entity top is
    port(cl_k: in std_logic
    end top;
    architecture Behavioral of top is
    --component random
    component random is
    generic (
    g_CLKS_PER_BIT : integer := 87 -- Needs to be set correctly--> 10 MHZ/115200(baud rate)
    Port ( clk :in STD_LOGIC;
    output : out STD_LOGIC
    end component;
    --component uart rx
    component receive is
    generic (
    g_CLKS_PER_BIT : integer := 87 -- Needs to be set correctly--> 10 MHZ/115200(baud rate)
    port (
    i_clk : in std_logic;
    i_rx_serial : in std_logic;
    o_rx_dv : out std_logic;
    o_rx_byte : out std_logic_vector(7 downto 0)
    end component;
    --signal
    signal mlebu:std_logic;
    signal enabl:std_logic;
    signal metu :std_logic_vector (7 downto 0);
    begin
    a:random port map( output=>mlebu,
    clk=>cl_k
    b:receive port map( i_clk=>cl_k,
    i_rx_serial=>mlebu,
    o_rx_dv=>enabl,
    o_rx_byte=>metu
    end Behavioral;
    regards
    halim

  • Sending SAP image to email

    Hi all,
    I have to send image stored in SAP (Se78 or OAER) to email.
    Please help me in this regard.
    Thanks,
    Ananth

    Hi Ananth,
    You can search a lot in SCN for this.make advance search
    Check out the thread below,similar thread like yours.
    Re: Sending an image in Email
    regards
    Sachin
    Edited by: sachin sharma on Feb 26, 2009 3:28 PM

  • Hi does anybody know how to perform roundtripping between aperture 3 and lightroom 3? i can set up aperture to send the file to lightroom BUT i cannot get lightroom to send it back with the just the adjustment (it sends the image as a separate file)

    basically, i find the sharpening tool in aperture extreamly slow and would like to use lightroom, just for sharpening.  I then would like to send the image back to aperture as just an adjustment on the original file and not a whole new replica file as the original. can any body give a easy solution? cheers

    What you want to do can't be done.  There is no low-friction way to combine image adjustments from Aperture and Lightroom.  There is no way at all to combine them without creating new files.
    This was recently discussed in this thread.
    Are you using the Edge Sharpening adjustment?  In Aperture 3, it superceded the old Sharpening adjustment, which remains included for backwards compatibility.

  • Our regular photographer send us images that, unlike before, are now locked in rights and sharing. T

    Our regular photographer send us images that, unlike before, are now locked in rights and sharing. This means that we have to lock up every photo separately with the admin code and it takes time.
    Recent pictures from him came with read and write permissions. He says he has not done anything different than before.
    Could it be that there is a setting in our mac / photoshop which causes this?

    PS itself doesn't do any rights management, so it's unclear what you mean. If you have system levele permissions issues, you might want to review some of this stuff:
    Installation Preparations (security section)
    Mylenium

  • Sending attached images

    When I send a image file to a none mac user the file either does not attach to the mail or it embeds itself in to the e-mail and changes to a BMP file. The reply I get back from the recipient is there is no attachment, how ever the in the reply back to me the images are attached to there mail. Does anyone else have this issue and is there a way to send a jpg as an attachment and it stay an attachment for the recipient.
    Thanks
    Mitch

    Greetings,
    Attachments are not embedded into your email; that's a function of the recipients' email client, not Mail. If you attach an image, it doesn't change to a BMP file, since Mac doesn't use that file format for anything; the recipients' Windoze mail client would do that.
    If you want to send images, you have two options: 1) is to always check the Send Windows friendly attachments option; or 2) compress the images into a .zip file and attach that instead.

  • Sending Mail (Image Format)

    Hi Brothers and Sisters,
                          I want to send a image by mail in R/3.
    Any one can assit me.
    Edited by: abap.m on Jun 11, 2010 11:30 AM

    Are you trying to send the e-mail with the image embedded? I did it with PHP and Phython... Never done it in ABAP, sadly to say... but I guess it should be possible. You'll need to play with the way the HTML code of the e-mail is being created, using MIME and the right headers. I'm guessing the result of WWW_GET_MIME_OBJECT will be your 'Content-ID'.
    Do some google with "Send an HTML email with embedded image". Even if it's related to another programming language it might give you some clues about how to compose the e-mail and you'll be able to replicate the logic by using CL_BCS.
    An alternative would be to just attach the image to the e-mail.
    Cheers,
    Andres.

  • I'm involved in fashion and would like to know which Adobe program would be suitable for importing images and my company logo to design fabric and send as image to fabric printers? Thanks

    I'm involved in fashion and would like to know which Adobe program would be suitable for importing images and my company logo to design fabric and send as image to fabric printers? Thanks

    Adobe Illustrator.  Your company logo should be a vector file.  Image files can be "Placed" in Illustrator.  Artwork created for printing can be drawn in Illustrator and saved as .ai, .eps, and .pdf files which can be imported into your printer's RIP.  But, check with your print vendors and see what they require.  This does not rule-out Photoshop, however Photoshop can be limited.  So, it would be a good idea to have Photoshop and Illustrator loaded in your workstation with Illustrator being the go-to application.

  • How do I send an Image over a socket ?

    I'm trying to get the output from my webcam and send that data out to a socket. Now the output from the webcam is running I'm just not sure how to send it out over the socket.
    Server.java
    import java.io.*;
    import java.net.*;
    public class Server {
       public static void main(String args[]) {
         ServerSocket serverSocket = null;
         boolean listening = true;
         try {
         serverSocket = new ServerSocket(1354);
         System.out.println("Listening for Connections...");
         } catch (IOException drr) {
         System.out.println("Error Listening :" + drr);
         System.exit(-1);
         try {
         while(listening)
         new ServerThread(serverSocket.accept()).start();
         } catch (IOException er) {
         System.out.println("Error Creating connection:" + er);
         try {
           serverSocket.close();
         } catch (IOException err) {
         System.out.println("Error Closing:" + err);
    }When a connection is made it will start the webcam and send the image.
    ServerThread.java
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import com.sun.image.codec.jpeg.*;
    public class ServerThread extends Thread {
        public static Player player = null;
        public CaptureDeviceInfo di = null;
        public MediaLocator ml = null;
        public JButton capture = null;
        public Buffer buf = null;
        public Image img = null;
        public VideoFormat vf = null;
        public BufferToImage btoi = null;
        public ImagePanel imgpanel = null;
        private Socket socket = null;
        Image blah;
        PrintWriter out = null;
        public ServerThread(Socket socket) {
         super("ServerThread");
         this.socket = socket;
        public void run() {
         try {
             out = new PrintWriter(socket.getOutputStream(), true);        
             imgpanel = new ImagePanel();
                 String str1 = "vfw:CompUSA PC Camera:0";
                 String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
                 di = CaptureDeviceManager.getDevice(str2);
             ml = new MediaLocator("vfw://0");
                try {
               player = Manager.createRealizedPlayer(ml);
                 } catch (Exception npe) {
               System.out.println("Player Exception:" + npe);
                player.start();
             Component comp;
             if ((comp = player.getVisualComponent()) != null) {
               // Grab a frame
               FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
               buf = fgc.grabFrame();
               btoi = new BufferToImage((VideoFormat) buf.getFormat());
               //Send the image over the socket
               out.println(btoi);
         } catch (IOException e) {
             System.out.println("It bombed:" + e);
        public static void playerclose() {
           player.close();
           player.deallocate();
      class ImagePanel extends Panel {
        public Image myimg = null;
        public ImagePanel() {
        public void setImage(Image img) {
          this.myimg = img;
          repaint();
        public void paint(Graphics g) {
          if (myimg != null) {
            g.drawImage(myimg, 0, 0, this);
      }The output I get from running the server is this:
    BufferedImage@c9131c: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 320 height = 240 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    Now how can I turn this into an image If this output is correct?

    HUH?
    I got the one to send the images over the network. I'm now trying to get the exact feed of the webcam and sending that over the network. This is alot more difficult to accomplish but I did see where I messed up my process of sending the images was just having to save the file then open it up put it in a byte array then send that over the network to the client. Once it was at the client i was able to re-construct it and throw it up in the frame. The only problem was lag. So this tells me it would be much more faster if instead of saving the file to send the client and having to reconstruct the image I should just send the webcam feed i used to make the image.
    eh, I guess I didn't need any help.
    Hey no offense or anything but you really have to learn how to spell better.

Maybe you are looking for

  • The application detected an error that prevents changes from being saved.

    Hi. I'm having this problem almost all the time when I do some color correction. "The application detected an error that prevents changes from being saved. To avoid losing your work, quit Final Cut Pro." Any ideas why this is happening? I'm on a 2010

  • Best Monitor for Macbook Pro 13"

    i am looking to purchase a Monitor to enable me to use my MBP as a desktop when i get home with a wireless keyboard and mouse.  Anyone know which is the best monitor to go for? ideally between 21 and 27 inches? i was looking at a samsung but i have h

  • MBA instead of MBP for main computer?

    Hi, I'm currently trying to decide between the 13in. MBA and MBP. I'll be a junior in college and have finally decided to update my aging five year old Dell (the screen is coming off, it's gotten so bad). I was considering the 13 MBP two years ago, b

  • How to make a menu at the top of the page move to the left when scrolling?

    I have a menu on the top of the page on a sidebar-sort. I was wondering how you could make it move to the left, not until the scrollbar reaches the end of the page, but when I say so. If i put the key position under the menu, it disappears. If i put

  • Photoshop Lens profiles in Lightroom?

    There are so many more lens profiles in Photoshop, including one I need that is not in Lightroom. Is there a way to use or access those photoshop profiles without having to export or edit in photoshop? thanks in advance, J