Saving an Image to a file as jpeg or png

I am creating a paint program and would like to save whatever user has drawn to a file.
I can use BufferedImage but when i try to use buffered image then the display of the painting area is set to black and the painting colour is set to white even when i try to change it. How can i avoid this problem while still saving it. By the way the painting area is a custom subclass of JPanel.

Just look down the page a bit!
http://forum.java.sun.com/thread.jspa?threadID=606095&tstart=0

Similar Messages

  • Saving an image and data file

    Am am current developing a program similar to the one below using an elvis module.
    I am trying to save am image of the graph but, the save image window keeps popping up because of the loop.
    I just want to be able to click a button and then save the image to a file without the save window popping up every time. 
    Attachments:
    conor.vi ‏57 KB

    Hi cdwyer,
    In your second example's block diagram, you need to have the save button terminal and the associated case structure within your main loop, otherwise the button/case structure is only read/executed the one time.
    An additional tip: When saving "computer graphics", like LabVIEW panels or diagrams, it's nearly always better to save them using the PNG format. PNG format is both compressed (small file sizes) and yet also "lossless compression" (no image degradation) - also it's usually preferable to use true colour (24 bit colour depth).
    JPEG file type is a "lossy" type of compression that is designed for photographics - it will cause blurring and colour distortions when used with computer graphics.
    Mark.
    P.S. Worth a few star ratings?
    Message Edited by Mark H on 02-02-2006 12:11 PM
    Attachments:
    example2 modified.vi ‏72 KB

  • How can i convert an image into gif file as jpeg by using com.sun.image.*

    please help me to convert an image into gif format. i have used sun's impl com.sun.image.code.jpeg package to convert a buffered image into a jpeg file. is there any implementatioln available from sun to handle gif files.

    Many. Try for instance google with 'java image encoders'. Go to the URL http://www.google.com/search?q=java+image+encoders and be amazed of the wonders of modern web search tools.

  • Directly saving an image to a file?

    Greetings. I blundered around a bit and managed to acquire an image by using the BufferedImage class and save it with the ImageIO.write method. But the thing is, I'd like the image to be saved without being recompressed so that the resulting image file is a 1:1 copy of what I started with.
    If someone says "why not just copy it then" - I'm retrieving the image via ImageIO.read(url) from the web, so I can't just copy it. (erh... or can I?)
    digiro

    If someone says "why not just copy it then" - I'm
    retrieving the image via ImageIO.read(url)
    from the web, so I can't just copy it. (erh... or can
    I?)Don't open it in with ImageIO.read, but just copy the stream (look at openConnection in the URL API.

  • Saving cropped image to a file

    Hello,
    I have a big image, I've cropped it into small slices and saved them in a 2-Dimensional array as an "Image" object.
    Now I am trying to save each "Image" Object to an individual file.
    Now it's really weird because I can save the very first image element in array as a file, but the rest of the elements are BLACK!
    Below is the part of my code.
    ===========================================================
    for( int i=0; i < slicedImageArray.length; i++ )
    for( int j=0; j < slicedImageArray.length; j++)
    BufferedImage bi =
    new BufferedImage( slicedImageArray[i][j].getWidth(),
    slicedImageArray[i][j].getHeight(),
    BufferedImage.TYPE_INT_RGB );
    bi.getGraphics().drawImage( slicedImageArray[i][j].getSlice(),
    slicedImageArray[i][j].getXCoordinate(),
    slicedImageArray[i][j].getYCoordinate(), null);
    File sliceImage = new File("image" + i + j + ".jpg");
    try
    ImageIO.write(bi, "jpg", sliceImage);
    catch(Exception e)
    ====================================================================
    getSlice() method returns "Image object"
    PLEASE HELP!

    it is most likely because you are drawing the image off the range of the buffer:
    bi.getGraphics().drawImage( slicedImageArray[j].getSlice(),
    slicedImageArray[j].getXCoordinate(),
    slicedImageArray[j].getYCoordinate(), null);
    should be:
    bi.getGraphics().drawImage( slicedImageArray[j].getSlice(),
    0,
    0, null);

  • Saving screen image to a file? CP7

    Hi,
    In CP7, is there a way to save a screen shot to a file? I have a client who's users may not know how to capture a screen shot on their computer. We'd like them to be able to click a button on the slide and have an image of that slide (say certificate) be saved to a file on their pc.  Is this possible? How?
    Thanks!
      Lori

    This is not currently possible with standard Captivate functionality.  It might be possible with a widget, but I've not heard of one out there that does this.

  • Best file type; JPEG, TIFF, PNG etc

    I'm using Iphoto 5 (can't decide to buy 06 or buy new Imac - still thinking on that ...) and wonder what is the best file type to use. When importing pictures from my camera they are jpeg's (haven't tried raw setting yet)- from my scanner I use TIFF. It appears the TIFF files are a lot larger - 20 to 50mb compared to the jpegs 1 to 5mb. I've opened the TIFF files in preview and save as JPEG to reduce the size and also scanned using JPEG format - I don't see any advanatge to the larger tiff files and the smaller jpegs are easier manipulated - am I'm missing something?

    Hi Arlington,
    There is an important difference between JPG and TIFF:
    JPG uses a lossy compression!!!
    Just try to open a JPG and save it under a new name as JPG. Repeat this ten times and then compare the last picture (..the one that got saved and re-saved ten times as a JPG) with the original one you should see a difference, the quality of the last image should be a lot less than the original.
    That's the difference - if you want to edit your pictures (e.g. in Photoshop) and quality is your first priority then go with TIFF. If you just download the pictures from your digital camera and store them then JPEG is your best choice.
    HTH,
    Koinseb

  • Cannot import still image: jpeg/tiff/png/gif/ai/psd

    Hello all:
    I'm running into a strange error. No matter what size image I try, I cannot seem to import a still image into Adoe Premiere Pro cs4 running on Mac OSX 10.6.2
    The error I receive is a "File Import Error: File Video Dimensions width/height too large."
    I've tried the following to isolate why Premiere is returning this error:
    - importing images at different sizes: 100x200, 1000x2000 etc
    - saving the image as different file formats: jpeg, tiff, gif, png etc
    - importing it as an illustrator file
    - importing it as a Photoshop file
    None of that worked. I'm at my wit's end and I can't seem to find anybody that has experienced this error before.

    Here are some threads to check:
    http://forums.adobe.com/thread/387776
    http://forums.adobe.com/thread/480381
    http://forums.adobe.com/thread/387156
    http://forums.adobe.com/thread/443138
    IIRC, the third one is for the Mac, but might be useful info in all.
    Good luck,
    Hunt
    PS - welcome to the forum

  • How to see all image types when saving an image without selecting "all files"every time

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/951766]]</blockquote>
    Hallo, and thank you for reading this.
    I am a person who saves a lot of images online and renames them in different folders in different names like B - 34 or G - 56. I have been working with firefox 10 for quite some time and it had a pretty handy bug (I guess) where I could save an image and firefox would just save the image in it's original type (JPEG,PNG etc) while "save as type" was empty.
    It also always has shown all the image types in the folder where I save the images (except for GIF) and that helpes me quite a lot by saving me the trouble of selecting "all files" every time I save or going to the folder to rename every image.
    Now this seems to be lacking in the newest firefox versions and my question is if I can set firefox to always show me all the image file types when saving an image, instead of only showing JPEG's when I try to save a JPEG.
    Thank you for your time.

    I suspect this is a Windows problem. I am surmising the FilePicker uses the Operating System or Desktop facilities. Does Windows 7 offer any other file categories like ''images'' ?
    I do not normally use Windows 7, but may the option depend upon the directory being an indexed one, I ask after finding this thread ''Bring File types tab back'' [http://www.windows7taskforce.com/view/819]
    This question is a duplicate of [/questions/951764]
    Normally I would lock the duplicate question, but in this instance I will leave it open as it is unanswered and someone may give a better reply.

  • Saving jpeg and png files large file size

    Ive recently purchased web premium 5.5 and Im trying to save files in jpeg and png format in Photoshop and Im getting unexpectedly large file sizes, for example I save a simple logo image 246x48 which consists of only 3 basic colours and when I save it as a jpeg quality 11 it reports the file size in the finder as 61.6k, I save it as a png file and its 60.2k also I cropped the image to 190x48 and saved it as a png and the file size is actually larger at 61.9k saving as a jpeg at quality 7 the files size is a still relatively large 54k.
    I have a similar png non indexed colour logo on my mac I saved in CS3 on a pc which is actually larger at 260x148 and it's only 17k and that logo is actually more complex with a gloss effect over part of it. Whats going on and how do I fix it, It's making Photoshop useless especially when saving for the web
    Thanks

    Thanks I had considered that but all my old files are reporting the correct files sizes I have been experimenting and fireworks saves the file at png 24 at 2.6k and jpegs at 5.1k, but I don't really want to have to save the files twice once cut from the comp in photoshop and again in fireworks juggling between the two applications is a bit inconvenient even with just one file but especially when you have potentially hundreds of files to save.
    Ive also turned off icon and windows thumbnail in photoshop preferences and although this has decreased the file size they are still quite large at 27k and save for the web is better at 4k for the png and 16k for the jpeg. Is there anyway to get Fireworks file saving performance in Photoshop ? it seems strange that the compression in Photoshop would be second rate in comparison to fireworks given they are both developed by Adobe and Photoshop is Adobes primary image editing software.

  • Image is not saved in jpeg/bmp file but ok with png

    Hi i am unable to save the image in disk in jpeg format.
    Here is the code.
    public void saveImage(){
    //if no filechooser is there means no image file opened.
            if(fileChooser==null){
                if(errorWindow==null)
                    errorWindow=new ErrorWindow(XXX.getPrimaryStage());
                errorWindow.showErrorWindow("There is no image to save !!\n");
            else{
                fileChooser.setTitle("Save The Image");
                File saveFile=fileChooser.showSaveDialog(XXX.getPrimaryStage());
                if(saveFile!=null){
                    System.out.println("saveFile path= "+saveFile);
                    //get the extension of output image to be saved.
                    //XXX: is the main class name(say)
                    outExtension=*XXX*.getImageExtension(saveFile);
                    //if user does not give extension: set default extension as jpg
                    if(outExtension.equalsIgnoreCase(saveFile.getName())){
                        outExtension="jpg";                   
                        String newPath=(saveFile.toString())+".jpg";
                        saveFile=new File(newPath);                   
                    Task task = new Task<Void>() {
                        @Override
                        public Void call() {
                            Platform.runLater(
                                    new Runnable() {
                                        public void run() {
                                            try {
                                                //The image is inside ImageView->inside ScrollPane-> inside TabPane.
                                                Image curImage=XXX.getCurrentImage();
                                                int width=(int)curImage.getWidth();
                                                int height=(int)curImage.getHeight();                              
                                                System.out.println("cur image width= "+width+" ht= "+height);
                                                bufferedImage=new BufferedImage(width, height,BufferedImage.TYPE_INT_ARGB );
                                                //set the current image to awt Buffered Image
                                                SwingFXUtils.fromFXImage(curImage, bufferedImage);
                                                    imageTabPane=xxx.getImageTabPane();
                                                    Tab tab=imageTabPane.getSelectionModel().getSelectedItem();                                    
                                                    TabPane childTabPane=(TabPane)tab.getContent();
                                                    ScrollPane sp=(ScrollPane)childTabPane.getSelectionModel().getSelectedItem().getContent();
                                                    final ImageView imageView=(ImageView)sp.getContent();
                                                    WritableImage wim = new WritableImage(width,height);
                                                    imageView.snapshot(null, wim);
                                                    System.out.println(" snapShot width= "+wim.getWidth()+" ht="+wim.getHeight());                             
                                                    *ImageIO.write(SwingFXUtils.fromFXImage(wim,null), outExtension, saveFile);*
                                                       //<------ its not working  for png,jpeg,bmp,gif                                          
                                                    // the below lines are working only for png and gif
                                                    OutputStream out = new FileOutputStream(saveFile);                                                
                                                    ImageIO.write((RenderedImage) bufferedImage, outExtension, out);
                                                    out.flush();
                                            } catch (Exception ex) {
                                                Logger.getLogger(FileMenuController.class.getName()).log(Level.SEVERE, null, ex);
                                                //ex.printStackTrace();
                                            System.out.println("finished");
                            return null;
                    Thread th = new Thread(task);
                    th.start();
                }else{
                    System.out.println("File is not saved");
        }//saveImageNote: The above code is executed in ubuntu(10.04) using Netbeans 7.2(Javafx(2.2), java(1.7.0_11).
    When i run(from terminal) separately in a new class with an image in an Imageview( inside a Vbox) and take the snapshot
    of the imageview and write into the file using ImageIO.write(SwingFXUtils.fromFXImage(wim,null), outExtension, saveFile);
    with any extension (jpeg,png etc) it is working fine.
    Please help me.
    Any small hint is also helpful.Please feel free to comment or give suggestion.
    Edited by: 963038 on Feb 17, 2013 7:14 PM

    When i omit the line OutputStream out = new FileOutputStream(saveFile);
    and write only
    ImageIO.write((RenderedImage) bufferedImage, outExtension,saveFile);
    //out.flush();
    then saving the image even in "png" also fails.
    The following is the error code:
    Note : FileMenuController is my file where the saveImage() is wrtten.
    javax.imageio.IIOException: I/O error writing PNG file!
    finished
         at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1168)
         at javax.imageio.ImageWriter.write(ImageWriter.java:615)
         at javax.imageio.ImageIO.doWrite(ImageIO.java:1612)
         at javax.imageio.ImageIO.write(ImageIO.java:1536)
         at *newciptk.controls.menu.file.FileMenuController$1$1.run(FileMenuController.java:205)*
         at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
         at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
         at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
         at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
         at java.lang.Thread.run(Thread.java:722)
    Caused by: java.io.IOException: Operation not supported
         at java.io.RandomAccessFile.writeBytes(Native Method)
         at java.io.RandomAccessFile.write(RandomAccessFile.java:499)
         at javax.imageio.stream.FileImageOutputStream.write(FileImageOutputStream.java:124)
         at javax.imageio.stream.ImageOutputStreamImpl.writeInt(ImageOutputStreamImpl.java:91)
         at com.sun.imageio.plugins.png.ChunkStream.finish(PNGImageWriter.java:136)
         at com.sun.imageio.plugins.png.PNGImageWriter.write_IHDR(PNGImageWriter.java:401)
         at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1135)
         ... 9 more
    javax.imageio.IIOException: I/O error writing PNG file!
         at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1168)
         at javax.imageio.ImageWriter.write(ImageWriter.java:615)
         at javax.imageio.ImageIO.doWrite(ImageIO.java:1612)
         at javax.imageio.ImageIO.write(ImageIO.java:1536)
         at newciptk.controls.menu.file.FileMenuController$1$1.run(FileMenuController.java:205)
         at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
         at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
         at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
         at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
         at java.lang.Thread.run(Thread.java:722)
    Caused by: java.io.IOException: Operation not supported
         at java.io.RandomAccessFile.writeBytes(Native Method)
         at java.io.RandomAccessFile.write(RandomAccessFile.java:499)
         at javax.imageio.stream.FileImageOutputStream.write(FileImageOutputStream.java:124)
         at javax.imageio.stream.ImageOutputStreamImpl.writeInt(ImageOutputStreamImpl.java:91)
         at com.sun.imageio.plugins.png.ChunkStream.finish(PNGImageWriter.java:136)
         at com.sun.imageio.plugins.png.PNGImageWriter.write_IHDR(PNGImageWriter.java:401)
         at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1135)
         ... 9 more

  • Saving files in .jpeg - Photoshop Elements 10

    I suddenly got problems with saving files in .jpeg format. I use camera raw in my camera, and edit photos in Element, and then save a .jpeg version of the photo, and until recently that operation has went on without problems, but suddenly I got no other alternatives than .psd. Why?

    Hi,
    Most likely reason is that the image is in 16 bit format not 8 bit - a JPG can only support 8 bit formats.
    Try changing the mode: Image -> Mode -> 8 bits/channel
    If you use RAW images, you can set the colour depth when yo first open the image (see center of window at the bottom).
    Brian

  • Saving large tiff files as jpeg

    Hello, experts:
    I scanned, as a tiff file, a full-centre spread of a large newpaper. This had to be scanned in eight sections, the pages were so big on my A4 scanner window. When I joined all the sections up in Photoshop CS5, the size of the file was huge (about 21 inches by about 19 inches) It is also digitally large (about 320 MB, since the resolution is 300 dpi). Because I want to keep the composite photo but don't want the file to be so digitally large, yet need the good resolution, I thought it would be a good idea to save it as a jpeg file, which would give me the dimensions I need but not be so digitally bulky as the original. On pressing the drop-down menu for Saving As, the jpeg option did not appear in the dialogue box. Why is this, and how may I save the file in jpeg format? With grateful thanks to any/all that can offer a helpful response,
    True to form

    Curt, I'm very appreciative of the help you have given so far. However, I did try to change the image to an 8-bit as you recommended, and, though it is possible to make this change, and thereby reduce the sheer amount of data in the photo, when I click to choose 8-bit, the picture goes all bright and weird. This is because when I click on 8-bit, a window also arises, called HDR toning. In this window are lots of sliders, and, try as I may, it does not seem to be possible to adjust anything to make the picture normal in appearance. If you have any useful comment on what to do to make the picture like it is before the change to 8-bit, I should be glad to hear it. Thanks in anticipation.
    T.T.F.

  • How to set jpeg resolution when saving pdf file as jpeg

    I'm running Acrobat using interprocess api, I can invoke a script to save a pdf file as JPEG, but I need to be able to set the resolution of the saved jpeg file.
    Any clues as to how I can do that ?
    Peter

    Hi
    I am running a stand-alone version of Framemaket 10.I try to convert a documentation with a lot of screenshots in it. Regardless of the settings on the Reference pages of the first document of the book, Framemaker converts all graphic files to *.gif, and these are downsized so much that they become illegible. I would like to have them converted to JPG, with little resolution loss, so they are still readable.
    I think Robohelp is too expensive…
    Best regards
    REIDEN TECHNIK AG
    Alexander Keller
    Tech Writer

  • While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything.

    While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything. This is becoming incredibly frustrating. It happens at random time and a restart of the computer is all that helps, then with out any notice it starts to do this again.  Mac Book Pro i7 2.2 16 GB 1333 Ram, (2) 450GB SSD both internal to machine. At this point I am losing file because I am unable to save in the file type I need. Does anyone out there know how to solve this issue?
    Thanks
    phil

    I haven't been unify photoshop much in the past month, but I did try your suggestion and it seemed to work for a while. Today when i went to save a document the same thing happened: click on file>save at this point I can not click on save even though it is highlighted. Tryed to use command s that brings up the save dialogue box, but when I try to change file type I again cannot select it from the drop down menu.

Maybe you are looking for

  • For all the negative remarks about customers

    Its very bad that customers have to put up with these smart comments from some people. I see many remarks that people make against customer loyalty..[A company can't stay in business without customer loyalty} If a company treats you good and gives yo

  • Export CLOB field (long= 4202083) to a file with UTL_FILE.PUT or PUT_LINE

    Hello, I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE. But: - PUT does only export the 32565 characters. I see that the output of l_pos is 42

  • Case sensitive file extensions on mime.types?

    Hello, I'm facing a weird problem at customers's site. There is an iAS 10.1.3.3 installation on a Windows 2000 server. There is an OC4J container called "OC4J_FR" where their application is depoyed. The trouble we're facing is the following: on the %

  • SIP setup with Media5-fone and CUCM7

    I think I have configured it all correctly and I have viewed the netcraftsmen website but it differs a little. When I run a sip trace from Media-fone5 i see an error : Warning: 399 (CUCM name) " Line not Configured" I can not find out what line needs

  • How to hide the extra line when use the AI pen tool

    When I use AI CC  pen tool to draw a line, when i click the 1st anchor point,  " - " shows next to the Poniter  ( I did not drag ) ,I tried to move, but  an extra line coming out before I click another point. So I could not draw lines or curves!  Tha