Show a .tif image with ImageIcon?

I'm using ImageIcon class to display images, but I have a tif formatted image. ImageIcon doesn't seem to support it. Is there a work around?

Use the feedback link?

Similar Messages

  • How to show a tif image

    I want to show a tif in a JLabel
    I know Java work with gif and jpeg, but what 's about tif ?

    Well, you need a tiff decoder. AFAIK the new ImageIO API supports tiff, but if you're after something smaller I'm sure you'll find something useful from http://www.geocities.com/marcoschmidt.geo/java-image-coding.html

  • How to get a .tif image with n different colors?

    Hi..i want to know how can i get a .tif image colored by some colors. I want to do something like this:
    if(tifImage.pixel < 0.1) {
    tifImage.pixel = yellow;
    else if( 0.1 <= tifImage.pixel && tifImage.pixel <0.5){
    tifImage.pixel = red;
    up to n colors.
    I prove the next code, but it is not getting the colors i want.
    public void generateImage(BufferedImage bi,double alto,double medio,String output){
              int width = bi.getWidth(); // Dimensions of the image
              int height = bi.getHeight();
              // Some constant colors (as arrays of integers).
              int[] red = {255, 0, 0};
              int[] green = {  0,255,  0};
              //int[] blue = {  0,  0,255};
              int[] yellow = {255,255, 0};
              //int[] background = { 85, 85, 85};
              int[] background = { 255, 255, 255};
              // The original image data will be stored on this array.
              int[][][] imageData = new int[width][height][3];
              // We'll fill the array with a test pattern bars thingie.
              double[] pixelArray=null;
              for(int w=0;w<width;w++)
                   for(int h=0;h<height;h++)
                        if(bi.getRaster().getPixel(w,h,pixelArray)[0]>=9000){
                             //lo dejo blanco
                             imageData[w][h] = background;
                        else if(bi.getRaster().getPixel(w,h,pixelArray)[0]>=alto){
                             //lo dejo rojo
                             imageData[w][h] = red;
                        else if(bi.getRaster().getPixel(w,h,pixelArray)[0]>=medio){
                             //lo dejo amarillo
                             imageData[w][h] = yellow;
                        else{
                             //lo dejo verde
                             imageData[w][h] = green;
              // Now we have a color image in a three-dimensional array, where the
              // third dimension corresponds to the RGB components.
              // Convert the color image to a single array. First we allocate the
              // array.
              // Note that this array will have the pixel values composed on it, i.e.
              // each R,G and B components will yield a single int value.
              byte[] imageDataSingleArray = new byte[width*height*3];
              int count = 0;
              // It is important to have the height/width order here !
              for(int h=0;h<height;h++)
                   for(int w=0;w<width;w++)
                        // Rearrange the data in a single array. Note we revert RGB, I still don't
                        // know why.
                        imageDataSingleArray[count+0] = (byte)imageData[w][h][2];
                        imageDataSingleArray[count+1] = (byte)imageData[w][h][1];
                        imageDataSingleArray[count+2] = (byte)imageData[w][h][0];
                        count += 3;
              // Create a Data Buffer from the values on the single image array.
              DataBufferByte dbuffer = new DataBufferByte(imageDataSingleArray,width*height*3);
              // Create an pixel interleaved data sample model.
              SampleModel sampleModel =
                   RasterFactory.
                   createPixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                             width,height,3);
              // Create a compatible ColorModel.
              ColorModel colorModel = PlanarImage.createColorModel(sampleModel);
              // Create a WritableRaster.
              WritableRaster raster = RasterFactory.createWritableRaster(sampleModel,dbuffer,new Point(0,0));
              // Create a TiledImage using the SampleModel.
              TiledImage tiledImage = new TiledImage(0,0,width,height,0,0,sampleModel,colorModel);
              // Set the data of the tiled image to be the raster.
              tiledImage.setData(raster);
              // Save the image on a file.
              JAI.create("filestore",tiledImage,output,"TIFF");
    Thanks

    I tried that. When I open one image and set the exposure, then go to open the second image, nothing happens. I then saved one image as a psd file, then it would let me open the raw file a second time. When I had both open on the same screen and dragged the layer from one into another image, the layer size ended up being different than the other file. It was shifted down and to the left. I need these images to be pixel locked, and the user experience I went through did not allow me to do this.
    I also do not see a way to copy/paste layers between files.

  • Error saving TIF image with JPEG compression (IndexColorModel)

    Hi all,
    i recently came upon the following error:
    javax.imageio.IIOException: Metadata components != number of destination bands
         at com.sun.imageio.plugins.jpeg.JPEGImageWriter.checkSOFBands(JPEGImageWriter.java:1279)
         at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeOnThread(JPEGImageWriter.java:694)
         at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:339)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFBaseJPEGCompressor.encode(TIFFBaseJPEGCompressor.java:489)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriter.writeTile(TIFFImageWriter.java:1835)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2686)trying to save a tif file with jpeg compression. The code used is this:
      public static void main(String[] args) throws Exception{
        String s = "c:/sample images/gray_bug/graybug.tif";
        BufferedImage bi = ImageIO.read(new File(s));
        File outFile = new File(s + "-out.tif");
        ImageWriter writer = (ImageWriter)ImageIO.getImageWritersByFormatName("TIF").next();
        ImageOutputStream ios = ImageIO.createImageOutputStream(outFile);
        ios.setByteOrder(ByteOrder.LITTLE_ENDIAN);
        writer.setOutput(ios);
        TIFFImageWriteParam writeParam = new TIFFImageWriteParam(Locale.ENGLISH);
        writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        writeParam.setCompressionType("JPEG");
        writeParam.setCompressionQuality(1f);
        IIOImage iioImage = new IIOImage(bi, null, null);
        writer.write(null, iioImage, writeParam);     
        writer.reset();
        writer.dispose();
        ios.flush();
        ios.close();
      }The test image that creates the problem can be found here:
    http://s11.postimage.org/7wl195w8z/graybug.png
    Any ideas what might be wrong?
    I am using imageio 1.2-pre-dr-b04 and JDK 1.6.
    TIA,
    Costas

    I can't help you but here's an exercise for you. When you get an exception you can't explain yourself, try posting it in Google. With a catch: remove anything from the error message that is specific to you like a classname or a specific value.
    In this case there is nothing specific in the error message so try a search for "javax.imageio.IIOException: Metadata components != number of destination bands". One thing is for sure: you're not the first to run into this error.

  • How to change Images with ImageIcon

    Hello everyone, this is my first post on the forums.
    I am struggling at the moment to find a way to change images in my program. I am making a card game and when the user clicks a button it will replace the card he has with another card. I thought the following code would work but apparently it doesnt:
    String cardPathA = "image1.gif";
    ImageIcon imageCardA = new ImageIcon(cardPathA);   //cardPathA for example is image1.gif
    //during the program the user changes cards so it should now show image2.gif
    cardPathA = "image2.gif";
    imageCardA.setImage(cardPathA);The error occurs when compiling and it reads: "+setImage(java.awt.Image) in javax.swing.ImageIcon cannot be applied to (java.langlString)+".
    I have searched all over the internet and I haven't found anything. I would appreciate some help. Thanks :)

    im not really sure i made a quick example to show how I would change the imageIcon in a button, just change the paths for cardPathA and cardPathB for your pictures to get it working.
    The only other thing i can think of is maybe to call repaint() for the components you are trying to change the image?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class ImageChange extends JFrame implements ActionListener{
             final private String cardPathA;
            final private String cardPathB;
         private ImageIcon myImageIcon;
            private JButton changeCard;
            private int counter;
            private JPanel panel;
            private JButton imageButton;
         public ImageChange(){       
                changeCard = new JButton("Change Button");
                counter = 0;
                cardPathA = "1.gif";
                cardPathB = "2.gif";
                myImageIcon = new ImageIcon(cardPathA);
                imageButton = new JButton(myImageIcon);
            public void makeGui(){
                changeCard.addActionListener(this);
                panel = new JPanel(new BorderLayout());
                panel.add(changeCard,BorderLayout.NORTH);
                panel.add(imageButton,BorderLayout.CENTER);
                this.add(panel);
                this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
                this.pack();
                this.setVisible(true);
         public void actionPerformed (ActionEvent menuChoice){
                counter++;
                if(counter%2 ==0){             
                    myImageIcon = new ImageIcon(cardPathA);
                    imageButton.setIcon(myImageIcon);
                }else{
                    myImageIcon = new ImageIcon(cardPathB);
                    imageButton.setIcon(myImageIcon);
            public static void main(String[] args){
                ImageChange test = new ImageChange();
                test.makeGui();
    }Calypso

  • Load image with ImageIcon component

    Hello,
    I want to load an image whose name or path contains special character such as accents (a french name). So that generates an exception. For exemple for an image named caf�.jpeg I obtain this message :
    java.io.FileNotFoundException: /media/disk/images/caf��.jpeg (No such file or directory)
    Can you please help me.
    Thanks in advance.

    hi,
    get this sample example and develop
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.ImageIcon;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ji extends JApplet
    public Icon pulicon;
    public JButton b1;
        public void init()
            getContentPane().setLayout(null);
            this.setSize(744, 536);
            pulicon = new ImageIcon(getImage(getCodeBase(),"bullet.gif"));
            b1 = new JButton(pulicon);
            getContentPane().add(b1);
            b1.setBounds(50,50,42,42);
    //<applet code="ji.class" height="200" width="200"></applet>that gif picture from current dir, where your class file stores.. if u want specify the path there

  • Capture window shows the same image with Viewer

    Hi there,
    I'm trying to capture a movie from HDCAM-SR via Sony SR-5500 deck.
    Deck's settings look fine, It plays the tape very well, I can see it from it's original display screen.
    I think somethings wrong with my FCP setting.
    I use FCP 5.1. When I say CAPTURE, I see the same image in viewer and in capture windos. if the viewer is black, capture win. is black too. I tried to change my display settings, but it didn't work.
    I'm capturing it via KONA 3 card and 10 Bit Uncompressed.
    This happened before, but I don't remember how I get rid of that...
    thanks in advance

    scs...
    Can you take another shot at explaining this? I'm confused.
    CaptM

  • Lock screen shows blurred background image with Safari run and volume controls

    The normally sharp image in the lock screen is blurred. Run and volume controls for Safari are displayed at the top of the screen - volume slider moves, play button has no effect. I do not know how to return the screen to normal appearance. Wallpaper settings show normal image. There are no active movies or videos running.

    OK, I returned to the settings for Wallpaper and Brightness and selected a different Wallpaper - the problem went away. The cause may be that the specific wallpaper I had been using is no longer present for selection.
    John

  • Showing .tif images on browser

    Hi
    Currently I am doing one module where in I have to show the tif images (.tif extension) on the browser through servlet. I was wondering if there are any Java API's which I can use to show them. I am using JSP on the front end.
    Thanx very much!
    -Asheesh

    Well we need to store them as tif only and on request from net display them. We can store them temp on server as gif / jpg and clean them on a nightly basis but the the aim is to do the coversion tif to gif / jpg format on the fly (request) and not covert all into gif / jpg and then display.
    Thanx!
    -Asheesh

  • Acrobat 8 - IE7 - XP - TIF Images linked from website

    All,
    We use Adobe Acrobat 8 Standard and Professional on a number of Windows XP desktops that are updated nightly with a Windows Update Server.  We manually configure workstations to open TIF images with Acrobat such that they open just like a PDF would.  This worked GREAT until last week.  Some Windows Update (seemingly) has made it so that now when we associate .TIF files with Acrobat they open fine from the desktop, however if you open Internet Explorer, goto a page with a TIF linked, click the TIF, Explorer says that the file is not able to be opened with the default application and asks me to save.
    Expected Operation
    1. User goes to www.pagewithtif.com, clicks image.tif
    2. Explorer asks if they want to open or save
    3. User clicks open and Acrobat loads (just like a PDF).
    Observed Obersation
    1. User clicks file
    2. User greeted with "SAVE/CANCEL" dialog (no open!) saying the file cant be opened by the default application
    3. After saving, the dialog disapears with no open!
    I have tested this with a virgin Windows XP image with ONLY IE7 and Acrobat installed, no other configuration except configuring TIF's to be opened with Acrobat.
    IE has the Adobe Plugin listed.  PDF's work as expected.  It works fine in Firefox.

    I remember what the difference is. I used to have different choices. [Open] [Save] [Cancel]
    I used to Always choose OPEN for pdfs. I could choose to save later if I decided to keep the file. Is this a change that Adobe made? A browser plug-in, maybe?
    I really dont want to save EVERYTHING, and have to remember to drag it to the recycle bin later.
    Any help?

  • Find images with parent keyword tag only?

    I don't know how to describe this problem succinctly, so I don't know how to search for it in the knowledgebase or forums. Can anybody help?
    I want a keyword hierarchy with "US" as parent keyword of 50 states name keywords. I have many images with state keywords, but I also have some images that are tagged only with "US" but no state tag, as they are not specific to a state.
    How do I *easily* find only the images tagged "US" but with no state tags? Clicking on "US" in the keyword panel shows me all images tagged with "US" and all with state tags, but I just want the ones tagged "US".
    I can use "Find" to find "US" images NOT CONTAINING "AL AK AR AS AZ..." by enumerating all 50 states, but that's a terribly awkward way filter out images tagged with state names. I can't see a button or filter that shows only the images with a parent tag but without child tags
    Any ideas?
    Thanks ahead of time,
    Dave

    John, this seemed like a great idea.  I tried it, and it seemed to work.  There was an immediate problem because when there are lots of keywords it means a lot of scrolling and it can be hard to locate rail among rain rate rails etc. because the font is so small.  A second problem was that you are forced to mouse scroll - cant page down or up or use home or end. That can be a lot of scrolling. a third problem is that it seems you have to reselect flat view each time.
    a more serious problem is that it seems to have stopped working.  I'm not quite sure what i did but i have a keyword verb with 5 items and about 1125 child keywords (such as to sing to run etc.) for 1125 photos   i click on the verb arrow in the keywords so i bring up 1125 pictures of verbs.  now i go to metadata switch to flat view.  i can now see "verb" as a keyword in the metadata panel, but when i click on it, nothing happens - I still have 1125 selected photos.  Furthermore i cannot click on any other keyword in the metadata panel - that is nothing happens when i click.  if I return it to hierarchical view it is fine.  then Lightroom 4 64-bit stopped working.  when i restarted the program it was still in flat view and i was now able to click on the metadata panel and see appropriate collections.  then it stopped working again after i clicked on the keyword panel (but did not actually select anything).  in total i have about 3000 keywords and about 100000 photos on local and network drives.  it looks to me like flat view has some serious problems, but perhaps its something i am doing.... 
    i also have to say that even if it worked perfectly, i still might prefer other solutions because scrolling up and down for 3000 keywords can be tedious - its difficult to prevent overshooting and undershooting the mark.  if the keyword and metadata panels could be undocked that would probably be a big help.

  • Bridge doesn´t show preview of tif-images

    Hi,
    I uses Bridge CS6 on a Mac with MacOS 10.9.2. Suddenly bridge doesn´t show previews of Tif-images. It´s also impossible to fill in any metadata. The program also says that the image isn´t tagged with any color profile. I don´t have these problems with jpegs, only with Tif-images. I even get previews on the RAW-images. Does anyone know what the problem can be?
    Ulf

    I guess I have to try to reinstall the program.......
    I'm 99,99 % sure that won't help solving your problem because to possible being effective you also should use the Adobe Clean tool to get rid of a lot of the hidden files that just stay put during a normal reinstall. But if you want to do something easier instead of reinstall, quit Bridge and go to the user library (by default hidden per OSX 7, use Finder, menu Go with option to reveal this library)
    In the preferences folder is plist file for Bridge (com.adobe.bridge5.plist), drag this file to the trash. Then in same library go to the folder Caches / Adobe/ Bridge CS5 and inhere delete both plug in and folder called Cache. (this means recaching the previews and thumbs).
    Then restart Bridge holding down option key and again choose 'reset prefs'. All previous deleted items will be replaced with new, fresh and empty ones and you have an almost like factory settings Bridge without the need of reinstall.
    But I really suspect it comes down to the Tiff files so maybe also a reset of preferences in PS might be worth a try.

  • Image not showing in Abobe integrated with Java WebDynPro

    Hi All,
    Image is not showing in Abobe integrated with Java WebDynPro.
    I did the following:
    Added the image field in adobe form. in URL value set the value of context node binding. Binding set to none and size set to Use Original Size.
    Then in script editor i wrote
    this.value.image.href = xfa.resolveNode(this.value.image.href).value;
    at innitialize , javascript and client.
    I can see the image from the same url context value if image field is created directly in WebDynPro View.
    Can anyone suggest what is missing?
    Thanks and Regards,
    Nuzhat

    Try changing your line of code for this one
    this.value.image.href = xfa.record.Images.URL;
    Check that the url passed by scripting is correct with a messageBox for example.
    You can also try assigning a hardcoded url at scripting level to check if its works.
    Best regards, Aldo.

  • Images with black blotches showing up.

    I have a wierd problem with picture quality that just started showing up.
    The black detail in certain areas of the picture is becoming overly black. Blotchy black areas especially on the screen and in prints. Black detail becoming overly compressed. The gradation between light and dark on my 23 HD and 17 Cinema display shows as layers of black, not a continual gradation to black. To explain it another way, the gradation of black colors (when going from light to dark to black) appears on the screen almost like Newton's Rings. I'm starting to get blotches of black in the darker areas of my monitor images and now on the prints. All the pictures are RAW (shot in Adobe 1998) from a Nikon D70s. None of the images have been altered in any way. No color correction, exposure increase or decrease, nothing. Straight RAW files imported directly into Aperture from the camera. I have printed all these pictures before and they looked fine. Now they have these black blotches in them. Not all pictures have the problem but the ones that have the darker black gradations (primarily to deep black).
    I have a custom .ICC profile I use for printing and the monitor was calibrated too, using ColorVision tools. Spider2Pro and PrintFix Pro. But even is I use the standard profiles for the monitor and the printer, it's still the same.
    The wired thing is, if I open the image with an external editor, Photoshop CS2, I do NOT get the same problems on the screen as I do with Aperture. (I have not printed yet from Photoshop CS 2 since this started, only viewed.)
    This is just a recent problem, and as I said, I have been printing the same pictures before and viewed the same pictures before with no problems. I noticed this starting to happen after the last 2 updates for Aperture, and it has progressively gotten worse.
    Any picture that has a continual gradation from a light black to dark black to full black has this problem. (On a 9 zone gray scale - say zone 5 thru 9)
    Equipment Notes: Aperture 1.1.2, Mac OS 10.4.7, Apple 23 HD display, Apple 17 Cinema Display, Dual 2 GHZ PowerPC G5, 3.5 GB RAM, 2 SATA internal Hard Drives, (the one with Aperture has 30 GB's left on it and the other that I use as Vault Back-Up has 164 GB's available. Video Card - ATI Radeon 9600 Pro, AGP bus, 64 MB RAM
    Epson Printer - R2400, using K3 inks on Premium PhotoLuster paper.
    Does anyone else have this problem? Do you know how I send this problem to the Aperture Team?
    P.S.
    I too have notice a tremendous slow down in Aperture as of late as other people have stated.
    I too sometimes don't get a image in the viewer. I sometimes only get the Right half of an image in the view. I can get other pictures to the left and to the right of the image in question but Aperture sometimes just picks a picture to only give me half. I must shut down and re-open Aperture to get the complete picture on the screen again. I can't figure that one out.
    Thanks,
    Jim

    Well, besides my 2 previous posts, I would like to add something. I started printing and everything was going well once I turned On Screen Proofing off.
    Oh, I guess I must first point out that I have calibrated my Monitor and Printer, using ColorVision's Spyder2Pro for the monitor and their PrintFIX Pro for the printer. It looks pretty good. But here is the problem.
    As I started to say, after I turned off On Screen Proofing everything looked good, on my screen and my prints. I started to print using my Colorvision settings and my custom ColorVison printer profile. It worked for a while on some prints but I ran a print with a long gradation of black to deep black and that replicated my original problem. Blotchiness and striations of black. I found that if I printed with Epsons' ICC profile it was fine. So the ColorVision profile didn't work on some prints with deep gradations of blacks.
    So I called their tech support. They asked if I did their 225patch target or the more extensive 700 patch target (I'm not sure of the correct number of patches). I had done the shorter 225.
    They told me this is a common problem if you only do the 225 Patch Target and that I would have to do the 700 Patch Target to not get black patches/striations in my prints. As a note: the striations looked exactly like the On Screen Proofing problem when it was turned on.
    So as it turns out, I had 2 problems at the same time.
    I haven't done the 700 patch test yet. I'll let you know when I get it done, how it works out and if the On Screen Proofing matches the print as suggested by firstlaunch.
    thanks for all your help and suggestions!

  • Connecting tif image stored in DMS with Material Master

    I am not sure if this is the best forum for this question. If not please let me know.
    I am storing tif images into DMS. I would like to connect them to the material masters they represent. What would be the best way to go about this process?
    Thanks much for your help.

    Hi Tom,
    Please go through the forum rules before posting.This is a very basic question and has been discussed several times over in the earlier posts.A simple search would yield you with the desired results.
    Regards,
    Pradeepkumar Haragoldavar

Maybe you are looking for

  • Apple loops shrinks creating a gap when Flex mode is on

    I've notice this happens me always with any apple loop. when drag to the arrange window, it behaves at it should, (say, 8 beats, occupy 2 measures and loop correctly), after flex is applied on that same track/loop, it shortens and doesn't loop correc

  • Export in background mode

    Does anyone know how to run an export in background mode for windows ? Normally in unix I would simply nohup the expdp command. Also what is the purpose of being able to reattach to a job in Data Pump - that in itself would suggest the export is alre

  • How do i import videos from my iPhoto to my iMovie?

    I need to know how to import video clips from my iPhoto to my iMovie to put into a movie. I know how to import pictures from iPhoto to iMovie but not video clips. Help??

  • Cannot start background process DTPR_13362_

    Hi ,     Whenever DTP  is executed  in the Dev Server,it throws an error. Error  msg: Cannot start background process DTPR_13362_1 26.09.2011 14:17:44 1 Min. 50 Sec. while checking the message in the monitor screen the cursor is at this function. CAL

  • Planning version in Characteristic Based Planning?

    What is the use of planning version in Characteristic Based Planning?