Save screen as .gif in Java 1.1

Hi, I have a frame that the user draws on, and I need to save the contents of this frame as a .gif file. I'm running Java 1.1. Can anyone help? Thanks.
import java.awt.*;
import java.awt.event.*;
class PaintArea extends Frame
    static int x, y;
    static Graphics g;
    PaintArea ()
        addWindowListener (new WindowAdapter ()
            public void windowClosing (WindowEvent e)
                System.exit (0);
        setSize (400, 400);
        show ();
        g = getGraphics ();
        hide ();
    public void loadArea (PaintArea pa)
        pa.show ();
        pa.addMouseListener (new MouseAdapter ()
            public void mousePressed (MouseEvent me)
                x = me.getX ();
                y = me.getY ();
                g.fillOval (x - 5, y - 5, 10, 10);
        pa.addMouseMotionListener (new MouseMotionAdapter ()
            public void mouseDragged (MouseEvent me)
                x = me.getX ();
                y = me.getY ();
                g.fillOval (x - 5, y - 5, 10, 10);
    public void saveScreen (PaintArea pa)
}

java doesn't have any included writers for gif files. you can write a gif if you find a plugin elsewhere, but i believe unisys still has a patent on the compression part of the format--so any free gif writer you find will either write uncompressed gifs, or be illegal. :)
why not save as a jpg or png instead? png is a pretty nifty format -- it's totally free, as in no licensing inssues, and the format is easily found. plus, most browsers these days can do png's.
to save an image as a png....
File outfile = new File("put/your/path/here.png");
javax.imageio.ImageIO.write(your_image, "png", outfile);the process is similar for jpeg files. just replace 'png' with 'jpg'. :)

Similar Messages

  • Save For Web always saves as a GIF

    Hi Guys,
    I think I may have a bit of a bug with Photoshop CS6 on my Mac. Every time I try to save an image through Save For Web, the file will automatically save as a GIF, regardless of what option I choose from the drop down menu. I have tried a reinstall of Photoshop and checked my setting against someone elses machine but I can't seem to resolve the problem.
    When I enter the Save For Web window, in the bottom left hand corner it says 'GIF' (just above the preview button and zoom button), if I was to change the drop down menu in the top right hand corner to JPEG or PNG, the GIF in the bottom left hand corner would stay the same, meaning that the file format would stay as a GIF.
    I've added an screenshot to show whats going on, the image in the preview is just text with a outer glow around it.
    Any ideas on this, as i'm a bit stumped on what my next move should be.
    Cheers,
    Chris

    Never seen this problem before. Have you tried the classic; resetting your preferences?  http://forums.adobe.com/thread/963474?tstart=0

  • How do I save a xls document in Java

    Hi!
    How do I save a xls Document from java?
    I mean, I want to specify which xls document to save and then save it.
    Any useful code would be of great help!

    This is the code!
    import java.io.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.Locale;
    import jxl.Workbook;
    import jxl.WorkbookSettings;
    import jxl.write.Label;
    import jxl.write.WritableCell;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableImage;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import jxl.write.Number;
    import jxl.write.*;
    import java.io.IOException;
    import java.io.OutputStream;
      public class writeXls
            public String templateName;
            public String outputName;
          public writeXls (String t, String o)
             templateName = "c://"+t;
             outputName = "c://"+o;
          public void writeYearVolume(String []yearvolymeArray)
              WritableWorkbook workbook = null;
              try
                  // Setup workbook
                  WorkbookSettings ws = new WorkbookSettings();
                  ws.setLocale(Locale.UK);
                  ws.setEncoding("Windows-31J");
                  // Load workbook
                  Workbook template = Workbook.getWorkbook(new FileInputStream(templateName));
                  // Create new workbook
                  workbook = Workbook.createWorkbook(new FileOutputStream(outputName), template, ws);
                  // Create new sheet
                  WritableSheet sheet = workbook.getSheet(1);
                  // Create new label
                  Number amc1000= new Number(4, 1, Integer.parseInt(yearvolymeArray[0]));
                  Number amc800 = new Number(4, 2, Integer.parseInt(yearvolymeArray[1]));
                  sheet.addCell(amc1000);
                  sheet.addCell(amc800);
                  // Write wookbook
                  workbook.write();
                  workbook.close();
                catch (IOException e)
                  e.printStackTrace();
                catch (WriteException e)
                  e.printStackTrace();
                catch(Exception e)
                    e.printStackTrace();
      }The xls file is modified but not saved, how do I save the file?
    Some of the cells in the xls file contains formulas, because of that, the cells containing formulas dosen't update its value.
    if I however save the file manually then the cells are updated. I want to save the xls file automatically from Java.
    Any ideas on how to do that?

  • I can't open ibooks. There was a screen pop up about java se. Help please.

    I can't open ibooks. There was a screen pop up about java se. Help please.

    Hi there ajsupprt,
    It sounds like you may need to update the version of Java installed on your computer. Take a look at the article below for more information.
    Java updates available for OS X on August 28, 2013
    http://support.apple.com/kb/ht5648
    -Griff W.

  • Generating Animated GIF in java is it possible

    Hi,
    I have worked on generating GIF / JPG Files in java. Now that i would like to know if its possible to create animated GIF in java. I have'nt got any examples on that. If anyone has any, can you pl post them here?

    This is an animated gif encoder : http://jmge.net/java/gifenc/
    Animated GIF Example :
    import net.jmge.gif.Gif89Encoder;
    void writeAnimatedGIF(Image[] still_images,
    String annotation,
    boolean looped,
    double frames_per_second,
    OutputStream out) throws IOException
    Gif89Encoder gifenc = new Gif89Encoder();
    for (int i = 0; i < still_images.length; )
    gifenc.addFrame(still_images);
    gifenc.setComments(annotation);
    gifenc.setLoopCount(looped ? 0 : 1);
    gifenc.setUniformDelay((int) Math.round(100 / frames_per_second));
    gifenc.encode(out);

  • Drop down "save" screen too large

    I frequently save web pages as PDFs.  When I select "save" or "save as" from the file menu, a drop down page opens to allow me to select the location in which to save the data.  The bottom of this new page extends beyond the screen so that I am unable to see or select the "Save" button to commit to the location.  The original screen is sized correctly , it's only this "save" screen that is too large.  How can I resize this drop down page?

    Hi
    quitting Safari then trashing
    Home/Library/Preferences/com.apple.safari.plist
    should reset that & anything else customisable... but if you'd rather keep other changes, try the following command in Terminal, after quitting Safari
    I'm assuming that you do mean the Save window created when say on this page, you choose File - Save as...
    defaults delete com.apple.safari NSNavPanelExpandedSizeForSaveMode
    you could also likely click the expand/contract arrow next to the 'export as' name box - which will make the window smaller & thus hopefully usable - but remove some of its features, including the corner drag to alter its size.

  • Since upgrading to Lion, i am unable to take screen shots.  i get the message that i don't have permission to save files to the place where SSs are saved.  how can i regain the ability to save screen shots?  thanks

    since upgrading to Lion, i am unable to take screen shots.  i get the message that i don't have permission to save files to the place where SSs are saved.  how can i regain the ability to save screen shots?  thanks

    First of all, are you using the OS native screen capture?
    If not, make sure the application you're using has been update for Lion.  I was using Snapz Pro for years, but I need to update it for use with Lion. Meanwhile Grab and the keyboard shortcuts are working on my Lion load.
    If you are using the native capture mode unsuccessfully, I would run the Disk Utility and repair permissions on the drive. For some reason, even in past OS Versions, routine maintenance of permissions makes life a lot easier.

  • How To Save Screen Shot Photo From iPAD to JPEG FORMAT

    How To Save Screen Shot Photo From iPAD to JPEG FORMAT

    The "iPad format" is PNG (which is better quality than JPEG).
    There is no way to choose JPEG at the moment of taking the screen shot. You will need to convert the file using conversion software, probably on your computer. Google "convert PNG to JPEG".

  • I just bought the newest model for the MacBook Pro with Retina, and I am trying to save an animated GIF but it comes out as thumbnails, can someone please help, I am very much new to apple. Thank you in advance.

    i would just like know how to save an animated GIF, thank you.

    Follow the instructions to the letter here >    iPhone and iPod touch: Unable to update or restore

  • N70 Idle / Power Saver Screen

    Hi
    My Firmware version is: v 2.0537.1.7 18-09-05 RM84
    I'm on the Orange network (UK)
    Is there anyway to adjust/configure the small Date/Time/Call & Message info on the Idle / Power Saver Screen
    It's just too small for me to see - It was much bigger & clearer on my Nokia 6100
    Any advice would be appreciated!
    Regards,
    Curly :-)

    Do you mean the power saver screen as in when you havent touched the phone for a while then you get the SINGLE HORIZONTAL STRIP across your screen with the date time etc on it which occasionally alters position on the screen?? If this is the one you mean then no you cant make it any bigger nor does the network affect it either, its a nokia thing. If however you mean the Orange home screen date time etc with the icons down the left hand side, then this is network specific to Orange, i have it too, not ideal but you get used to it after a while! I've heard you can get it flashed and revert it to original Nokia settings but this invalidates your warranty and could create more problems with your phone!! I'm gonna put up with it, other than the Orange home screen i'm very happy with my N70. It'll do me another 6 months anyway till i next upgrade!!
    Andy

  • How combine a jpeg image & animated gif image & save  it as GIF ?

    i have an jpeg image, & also aminated gif image, how do i place the animated gif image over (in the center of the image) a jpeg image & save it as gif file ??

    First thing you need to do is stop thinking in terms of file formats once the files are in photoshop they are all the same. The exception being vector vs raster. But in this instance the process is rteally the same so 6 on one hand a half a dozen on the other. Or as some would say Tomatoe, tomahtoe(mispelled on purpose).
    The jpeg I would assume is the background image and the gif image is the fore ground object. Open the jpeg, and then place the gif file. As long as the fore ground object has transparency, your job is pretty much done. If not, then it will be up to you to mask what you want to keep vs what you don't and apply that selection to the foregrounds layer as a mask.
    Google the net or skim the users manual for the keywords - mask, selections, quickmask, pen tool, paths. Each of these can in one way or another take care of your issue.
    It would be worth your time to also go through the numerous videos about photoshop and see how its done.
    Either go to adobe tv,
    Itunes podcasts
    or one of the following web sites:
    http://kelbytv.com/
    http://creativesuitepodcast.com/

  • Java Swing - save JPanel as GIF/JPEG.

    WE are using Java swing to draw graph(Genes, SNP ,repeats etc related to bio-informatics).text files we are using are quite big eg- more than 25 MB. first it makes the process slow.One of our problem is to save whatever "we draw as an image file(GIF/JPEG file)" and another problem is save a data in a data structure(array,vector) which grow upto 15-20 MB.
    plotting this data makes the speed too slow.We want to optimize this.

    For saving images have a look at JAI - the Java Advanced Imaging API. It's got fairly straightforward ways of saving images. Note that saving as GIF images is not recommended; patents were placed on the encoding so it's no longer a free option. PNG will give you lossless compression like GIF but is more flexible.
    http://java.sun.com/products/java-media/jai/
    Saving the generated (mined?) data structure for future retrieval can be quite straightforward depending on how you're doing it. The easiest way is simply to serialise it (use an ObjectOutputStream) but this has compatibility problems if you change your data structure.
    Saving out in a custom format may seem like a lot of work but it's not all that hard to do. Alternatively you can use one of the Java to XML convertors - in your case this might generate too large a file, however.
    YOu can always use Java's zip functions to improve file size should this become problematic.
    Hope this helps

  • Creating a .GIF in Java

    i got a nice lil program that will create an animation in an applet, it uses double buffering and i was wondering if i could take the image being drawn and save it into a GIF so that i can have an animated GIF of what my applet is showing?

    Hi ,
    Here's a link to a forum thread which will help :
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5230701
    Also, I would suggest trying NetBeans6.0 . Also,see my blog on Learning Java with NetBeans
    http://blogs.sun.com/radhika/
    Radhika

  • Open, save and transfer files in Java

    I need to find methods that will enable me to open files using a string (i.e. fileOpen(C:\temp\theDocument.doc), save files in the same way and transfer (or copy) files between drives and directories.
    The files may be of any type (.doc, .jpg, .gif, .pdf, etc).
    Can anyone help me by giving example of code that will enable me to do this, I am new to Java.
    Thanks,
    Lindsay

    Try http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Save for web gif loop settings not working

    Photoshop CC 2014 Mac Pro 10.8.5
    When I change looping settings from "once" to "forever" when saving a gif it only loops once. I tried multiple times. In the end what got it to work was changing looping back and fourth from "once" to "forever" over and over and over until randomly the preview started looping. At that point when I saved it worked correctly.

    I’m not really sure; it could be a Mac problem.
    This is the Adobe statement on Lion:
    Mac OS 10.7 has some exciting new features such as Autosave, Restore, Versioning, Full Screen Mode, and more multi-touch gestures. For Adobe applications to fully support these features, additional product development is required. Adobe is working to address this issue.
    There is one other thing you could try. Open a photo in the Editor and then hold down the Cmd+Opt+Shift Keys and press the letter S
    It’s also possible to delete the save for web preferences and then re-start the program to re-build them. This involves holding down Cmd+Opt keys and clicking Save for Web under the File menu. However this may not be possible if save for web is grayed out.
    Please let us know if you get it fixed.

Maybe you are looking for