Saving screen as jpg or gif.

I need to save a portion of my screen as either gif or jpg format. Can anyone help me. One more thing is that it has to be done using jdk1.2. I know how to do it using jdk1.3, i.e., the Robot class, but I want it to be done in jdk1.2.
So someone pls help.............

Hi,
Check out the JPEGCodec class
provided by sun
regards,
Partha

Similar Messages

  • Saving file, but jpg and gif comes out garbled

    Would someone please help me? I'm at my wit's end here. I'm writing a program that reads a file and saves it, but it needs to read a maximum of 512 bytes before it starts to write. It needs to work with both text files and images.
    - It works fine with text files.
    - It works fine with bmp images.
    - It works fine with jpg and gif images under 512 bytes.
    - With a jpg or gif over 512 bytes, it comes out all garbled, but the same file size as the original.
    One thing is really confoozling me. When the image comes out garbled, I tried changing the files for both the original and the copy into text files by changing the file extension to .txt. Both the text files were identical! So if the data is identical, why is the copy not showing the same image as the original?
    import java.io.*;
         public class SaveFile{
              public static final int BUFSIZE = 512;
              public static final String LIBRARY = "C:\\";
              static int totalRead = 0;  //Total number of bytes in buffer (Max BUFSIZE).
              static int fileSize = 0;  //Size of whole file.
                  static String fileName = "";  //Name of file.
                 static char[] data = new char[BUFSIZE];  //The data in the file.
              public static void main(String[] args){
                            //Bytes already read by the buffer.
                      int charsRead = BUFSIZE; 
                          //Takes name of file from main argument.
                         for(int i=0; i < args.length; i++)
                             fileName = fileName + args;
    //Name of file including directory.
              String fetchFile = LIBRARY + fileName;
              File file1 = new File(fetchFile);
              * Reads a string from the file to data (char array).
                   BufferedReader reader =
    new BufferedReader(new FileReader(file1), BUFSIZE);
                   BufferedWriter writer =
    new BufferedWriter(new FileWriter(fileName));
                   //Will continue as long as buffer is full.
                   while (charsRead == BUFSIZE){ 
                        charsRead = reader.read(data, 0, BUFSIZE);
                        if (charsRead != -1) {
                             totalRead = charsRead;
                             write(writer);
                             fileSize = fileSize + totalRead;
                   reader.close();
                   writer.close();
              System.out.println((fileSize) + " bytes read and saved as " + fileName);
         * Writes data to a new file.
         public static void write(BufferedWriter writer) {
                   for (int j = 0; j < totalRead; j++) {
                        writer.write(data[j]);
    I stripped away the directory selection and error handling to make it simpler.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Cadvan1123 wrote:
    I think the best choice is to use a ByteArrayOutputStreamWrong. You do not need a ByteArrayOutputStream
    and I think that it uses ASCII encodingPossible, but you can't just make that assumption. On windows for instance, there's a good likelihood it could use ANSI. And BTW, ASCII is for the most part dead, as it has been superseded by UTF-8.
    Check out t [jacobs.io.DataFetcher in TUS|http://tus.svn.sourceforge.net/viewvc/tus/tjacobs/] for a threadable and optimal/close-to-optimal solution for reading in binary files.
    Edited by: tjacobs01 on Mar 20, 2010 2:56 PM

  • Can I open a PDF and save it as a JPG or GIF?

    I asked on the PageMaker forum about creating a jpg or gif of a book cover I created in PageMaker. The suggestion was to create a pdf of it (no problem), open it in PhotoShop, then save it in the format I need. I don't own PhotoShop, so downloaded the Album Starter Edition. For the book cover with photos on it, only the photos are imported; for the book cover with only text and solid-color boxes, nothing at all is imported. Does anyone know how to get the entire pdf into PhotoShop so it can be saved, intact, as a jpg or gif? Thanks!

    I think Downloader in PSE organizer has capabilty to extract images from PDF.
    Collin- Is there any other way in PSE to extract images from PDF. Pls tell us how hat can be done.

  • How do I change "save image" to save as jpg or gif rather than an html pointer to the image?

    When I try to download images it is saving them as an HTML file instead of the actual image. I want to save images in their native jpg or gif formats as they are on the web. Downloading wallpapers for example is not possible. Without this I'm not going to stick with Firefox which is unfortunate because so far I love everything else about it, especially sync. I tried to download a Buffalo Bills helmet to use as an icon for a Bills fan forum which I wanted a Firefox shortcut for on my homescreen. I had to use the Android browser to do that because of this problem. Ridiculous!

    Unfortunately, Firefox for Android works quite differently than desktop Firefox in this regard. On the desktop, if you open about:config and set browser.download.useDownloadDir to false, then you prompted for the save location and file name. On Android, this simply stops Save Image from working.
    I was able to access the file by renaming Images.htm to a real file name using the ES File Explorer app. But... if you save images often, that would get old fast.
    Note: I think the name Images.htm came from the Google images results page that I was saving from, and the file name will depend on the site. When I saved from a site where the images had their own names, .jpeg was appended instead of .htm.

  • Can an InDesign page be saved as a jpg file for use in Photoshop CS5 ?

    Can an InDesign page be saved as a jpg file for use in Photoshop CS5 ?

    mckayk_777 wrote:
    Just wondering peter what you think, instead of output to pdf you copy and then create create new file in photoshop and paste into that file. Is that sort of the same thing?
    Seems to be ok especially if you enlarge the object before you copy it into photoshop.
    I think what you are pasting (never bothered to try this) is just the screen preview, hence the need to enlarge. Why would you waste your time doing that instead of exporting to a high-res PDF?
    If you want only part of the page, check out http://indesignsecrets.com/free-layout-zones-add-on-is-incredible-productivity-tool.php

  • How to deal with addition of .jpg or .gif file

    how do i add a LARGE .jpg or .gif image to a JPanel? and is it possible to add JTextField or other features onto the .jpg or .gif file after the addition of the image?
    Thanks for the time and consideration.

    If you want the image to just be the background for a panel then you will need to subclass JPanel and override the paintComponent(Graphics) method. In the paintComponent(Graphics) method you will need to draw the image yourself using the Graphics.drawImage() method. For loading the image I would suggest using one of the ImageIO.read() methods.

  • Issue with saving Tiff as JPG

    I am an artist who is using Photoshop Elements 4. Recently, my photogrpaher took photos of my work in TIFF format and sent me a CD of the shoot. I opened one in photoshop, edited it and tried to save it as jpg. I kept getting a window which read: Could not complete your request because of a program error.
    My photographer and I are confused because this has never happened. I opened up a CD of his photos from a previous shoot to check and see if they could be saved as a jpg and had no problem. He uses a Nikon D700 and has not changed anything else.
    This is frustrating because I use these images for my business, etc. Granted, elements 4 is an older program but why now?
    I'd appreciate any help!   Thanks!

    There is an asterisk after the 8. Like:  RGB/8*
    Since your post my photographer figure out a quick fix for this crazy
    dilema. He had me open one of the TIFFS and save it as a PSD. Then, I copied
    it and pasted into a new blank file. I then was able to save it as a JPEG.
    He and I are still stumped over this but I'll be needed new photos soon and
    we'll see if this happens again. Thanks for your help.

  • Convert jpg to gif images

    I make an application that create jpg images with jfree chart.
    But my client need the graphics in GIF format.
    I need:
    1. A conver program to pass from JPG to GIF format
    or
    2. A program to generate graphics (pie 3-d with texts) in GIF
    Someone likes help me?
    Thanks.
    MIGUEL ANGEL CARO
    [email protected]

    JFreeChart is open source, I'm sure you can get a Java GIF encoder library and wedge it into the JFreeChart API to make it create GIFs.
    Why does it need to be GIFs, though?

  • How JPG or GIF Image open in MIDP?

    How my j2me application can support jpg or gif image format. I have tested png file in midp 1.0 and its not support other than png format( im not sure about midp 2.0 does it support or not). I have seen lot of mobiles those support gif and jpg file formats. Does j2me applications on those mobile can support other image formats?
    Plus it is possible that i can develop my own decoder for jpg or gif format. I know it possible, but im talking related to its processing power consumption. Or is there any third party api exist to support jpg or gif file format on midp. Please r

    Here is the code snap that read image from a URL.. I have tested this code on localhost & two different pc on lan in emulator.. but not in actuall mobile... but i hope it will work...
    Image image = null ;
    DataInputStream httpInput = null ;
    DataOutputStream httpOutput = null ;
    HttpConnection httpCon = null ;
    String url = "http://localhost:8080/images/picture.png"
    try
    httpCon = (HttpConnection)Connector.open(url);
    int bufferSize = 512 ;
         byte byteInput[] = new byte[bufferSize] ;
         ByteArrayOutputStream imageBuffer = new ByteArrayOutputStream(1024*50);
         httpInput = new DataInputStream( httpCon.openInputStream() );
                   System.out.println("Http-Input Connecting Establish Successfully");
                   httpOutput = new DataOutputStream( httpCon.openOutputStream() );
                   System.out.println("Http-Output Establish Successfully");
    int size = 0 ;
    // read all image data ....
         while ( ( size = httpInput.read( byteInput , 0 , bufferSize ) ) != -1 )
                        imageBuffer.write( byteInput , 0 , size ) ;
    // get byte from buffer stream
              byte byteImage[] = imageBuffer.toByteArray();
                   System.out.println("read byte " + byteImage.length );
         // convert byte to image ...
         image = Image.createImage( byteImage , 0 , byteImage.length );
         return image ;
         //return null ;
    catch( IOException e )
                   System.out.println("\nUnable to Perform Image IO Operation with Host");
         return null ;
    ....................................

  • How can we put .ICO file on JButton instead of JPG or GIF etc. files

    How can we put .ICO(Icon file) file on JButton instead of JPG or GIF etc. files
    Regards
    Satinderjit

    Short answer:
    You don't. ICO files are a native windows format.
    Workarounds:
    1) Convert your files to GIF.
    2) Search for a library that can load ICO files.
    3) Write a library that can load ICO files.

  • Save part of a screen as jpg

    is there another way to save part of screen as jpg besides
    bitmapexporter (quasimondo)?
    i use as2.
    thanks

    It is doable, but not with actionscript 2.0 you need to run
    Actionscript 3.0 and then you can use the jpegencoder class to grab
    parts of the screen or even the whole screen

  • Why won't my trial of CC Photoshop let me save my PSD images as JPG or GIF?

    Why won't my trial of CC Photoshop let me save my PSD images as JPG or GIF?

    One thing to check is that your PSD is RGB/8 or /16, but not /32  (32 bits per channel)
    If that is not the problem
    Let's try this:
    Close Adobe Photoshop if it is opened.
    Find the following:   (windows user can hit windows key + r, then in run cmd line type "%appdata%" to locate your "AppData\Roaming" directory)
    \AppData\Roaming\Adobe\Adobe Photoshop CC\Adobe Preferences CC Settings
    Rename the  "Adobe Preferences CC Settings" folder to "Adobe Preferences CC Settings_old"  so that preferences settings can be recreated.
    Reopen Photoshop CC and open a new or existing file to verify that your "save for web" option is back and not grayed out.

  • JPGs and GIFs in Coverflow not showing

    For some reason the cover view in the Finder is no longer showing previews of JPGs and GIFs, but is only showing the generic icons for each.
    Any clues as to what's causing that and how to fix it?
    Cheers.

    Try deleting the Finder.plist preference:
    /Users/Kenny/Library/Preferences/com.apple.finder.plist
    Then relaunch the Finder.
    Thanks ... Ken

  • Generate JPG or GIF Report

    Hello Members
    i want to generate a report in JPG ,GIF or any others picture type,,
    the reason is that our client need a invoice and we send the invoice by scaning
    so any body tell me how i generate the report in JPG or GIF
    i am using oracle report 6i

    Dear
    first we mail the invoice , but now they say (our client) that now mail the invoice as picture format like jpg, gif
    i don't know how to do it,, they say if oracle report convert in MS word , excel or
    others non-oracle format so why do u not mail us in picture format
    i have to do just for there requirement
    thanks for reply

  • How to convert bmp to jpg or gif??

    hi all.
    I would like to store image into database and retrieve it. But I don't know the method that can show bmp image. So I need to convert it before keep in database in type of jpg or gif?
    Can you give me any suggestion?
    or if you know how to show bmp image,tell me.
    Thank you

    Load the BMP into Microsoft Paint. Save it asJPG.
    Which version of MS Paint do you use? Because theone
    I've got only lets you save as .bmp. I'd use
    PaintShopPro.
    I'm using the version that came with my Windows 2000
    machine. But you're right, I'd forgotten that it
    didn't do that on my old Windows 98 machine.In that case ACDSee is a good tool to do this sortta conversion.

Maybe you are looking for

  • Using Java2 Platform Standard Edition

    This is my first time using this forum and I am not sure if I am in the proper place. The edition of java I have is listed as above in Java Cntl Pnl but says J2SE Runtime Environment 5.0 Update 6 in my A/R Programs list. My problem is that I keep get

  • How do I take a pdf out of my email and transfer it to adobe so I can print it off my pc?

    How do I take a pdf out of my email and transfer it to adobe so I can print it off my pc?

  • XML header for WebServices (SOAP)

    Hi all! I have quite strange problem about XML header in SOAP message for WS. Usually I don't care about XML header in SOAP message, because so far I had no problems calling load of WS on different servers. Stnadard XML header that comes out looks li

  • GroupWise 7.0 on 3 machines

    Im planning to migrate my GroupWise 6.5 on netware 5.1 to GroupWise 7.0 oes2 (1500 users in one location). But at the same time id like to move the current system from one server to three machines. I decided to put on the 1st machine - domain and MTA

  • Odd PC Firefox bug with video

    I have a strange issue that's only popping up with Firefox on a PC. If you click the following link it loads a video player that has a tabbed interface on top. As each video finishes playing it's supposed to switch to the next tab and then begin load