Opening tiff image file and finding pixel values at each point

I want to open a tiff image file using java.Than i want to find out the pixel values at each point.Also if possible red,green and blue values.
please mail me answer or code if possible on mail id:
[email protected]

Use Java Advanced Imaging to open the Tiff. There is
a tutorial on it. Look to the left for tutorials, look
for JAI, do what it says.
For getting the pixels, do this:
Use a PixelGrabber to get pixels in array:
int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
pg.grabPixels();
Use a MouseMotionListner for
mouseMoved(MouseEvent moueEvent)
pixel = pixels[mouseEvent.getX() + (mouseEvent.getY()*width)]
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
Look up the API for MouseMotionListener, PixelGrabber, etc...

Similar Messages

  • A generic error occurred in GDI+ while assing tiff image file to Bitmap and Image

    Hi,
    I am getting "A generic error occurred in GDI+" error while reading the tiff image file to Bitmap or Image.
    Below is my sample code.
    string filePath=@"c:\Images\sample.tif";
    Bitmap bmp=new Bitmap(filePath);   // here getting exception
    int totalpages=bmp.GetFrameCount(.....);
    etc......
    I tried using Bitmap.FromFile() and also from FromStream() even for Image also but there is no use.
    Moreover i m having full permissions for the file path and the tiff file is having multiple pages.
    Can anyone help me to solve this issue please.
    Thanks & Regards,
    Kishore
    Kishore

    Make sure that the Tif file is valid (can other software open it)?  If you are able to save a Tif using GDI+, try saving that Tif, then opening it.  Part of me wonders if there is something about that specific Tif that GDI+ doesn't like.
    You could also try using WIC to open the TIF, perhaps you would have better luck there.

  • How to open a pdf file and then attach it with images

    I am new to Indesign Server.
    I'm currently working on a pdf.
    I have a white blank pdf template.
    that I want to attach/glue it with images.
    How to open a pdf file and then attach it with images.
    Please, help me.
    Thanks.

    First step would be to make yourself familiar with InDesign desktop version.
    Whatever you intend to achieve, do it there manually. (see regular app docs or forums)
    Then try to automate your steps with scripting (see scripting docs or forum)
    If you can do it with a script in the desktop version, that script will likely also run in ID Server. (see server forum).
    If you can specify missing features not achievable thru scripting or manual use, reconsider to write a plugin (this forum).
    A seasoned C++ programmer will need a few months to learn the basics, wade thru tons of documentation etc. Alternatively consider to hire a consultant to do the development work for you.
    Dirk

  • I can not open raw image files from my Cannon 5d mark iii with cs6 and my cs6 in mac

    I can not open raw image files from my Cannon 5d mark iii with cs6 and my cs6 in mac

    The Mk III requires an updated version of Camera RAw, so run Help --> Updates and install it.
    Mylenium

  • Open Tiff image failed with imageio package

    I'm trying to open tiff files with javax.imageio.ImageReader. When openning the image file, "bad.TIF" with the following codes, I got an error. However, I can open the image with "Windows Picture and Fax Viewer" (WPFV). After I opened/saved as File "good.TIF" with WPFX, I can open the image with the progarm. Would someone please help? Thanks.
    Error position is 2
    java.lang.ArrayIndexOutOfBoundsException: 2012
         at com.sun.media.imageioimpl.plugins.tiff.TIFFFaxDecompressor.nextNBits(TIFFFaxDecompressor.java:1503)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFFaxDecompressor.decodeNextScanline(TIFFFaxDecompressor.java:792)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFFaxDecompressor.decodeT4(TIFFFaxDecompressor.java:1040)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFFaxDecompressor.decodeRaw(TIFFFaxDecompressor.java:677)
         at com.sun.media.imageio.plugins.tiff.TIFFDecompressor.decode(TIFFDecompressor.java:2514)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.decodeTile(TIFFImageReader.java:1137)
         at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1417)
         at javax.imageio.ImageReader.readAll(ImageReader.java:1050)
         at com.rxamerica.image.LoadTiff.main(LoadTiff.java:35)
    import java.io.File;
    import java.io.IOException;
    import java.util.Iterator;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.ImageInputStream;
    public class LoadTiff {
    public static void main(String[] args)
    String myDir = "./";
    String testFile1 = myDir + "good.TIF";
    String testFile2 = myDir + "bad.TIF";
    int errorPos = 0;
    ImageInputStream tiffStream = null;
    ImageReader reader;
    try {
    reader = getReader("TIFF");
    IIOImage tiffImage = null;
    errorPos = 1;
    File file = new File(testFile1);
    tiffStream = ImageIO.createImageInputStream(file);
    reader.setInput(tiffStream);
    tiffImage = reader.readAll(0, reader.getDefaultReadParam());
    errorPos = 2;
    file = new File(testFile2);
    tiffStream = ImageIO.createImageInputStream(file);
    reader.setInput(tiffStream);
    tiffImage = reader.readAll(0, reader.getDefaultReadParam());
    catch (Exception e) {
    System.out.println("Error position is " + errorPos);
    e.printStackTrace();
    public static ImageReader getReader(String suffix) throws IOException {
    Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
    if (readers.hasNext())
    return (ImageReader) readers.next();
    else
    throw new IOException("No readers for suffix: " + suffix);
    }

    Can you upload the bad tiff to an [image hosting site|http://www.imagehosting.com/]?
    In general, when you set the input stream on a reader for a second time, it's a good idea to call reset.
    errorPos = 2;
    file = new File(testFile2);
    tiffStream = ImageIO.createImageInputStream(file);
    reader.reset();  <----- this line
    reader.setInput(tiffStream);
    tiffImage = reader.readAll(0, reader.getDefaultReadParam());I don't think that's the source of your problems though. You can add an IIOReadUpdateListener and a IIOReadWarningListener to the reader to see just how far it gets just before the exception is thrown. It may very well just be a badly saved tiff, or it could be a tiff image reader bug.
    Edited by: Maxideon on Jan 19, 2009 7:07 PM
    BTW, which version of JAI-ImageIO are you using?

  • Opening an Image File

    Hi! I'm trying to open an image file in an application using JFileChooser. As I open the file, I know that the file has already been selected but I don't know how to put it on the correct container. I'm trying to show the image on the upper box such that it would look like it is currently showing the current image and the lower box would show the filmstrip view of the images in the folder. Basically I have a JFrame and then a JPanel1 on the JFrame. I also have another JPanel2 inside the JPanel1 and it is in the place of JPanel1 that I want to put the image. Anyway, I'm stuck as to what should I use to contain the image on the upper box (JPanel1, currently it doesn't work for a JPanel). I can't see the image I'm trying to open. Any idea or help will be appreciated.
    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
        // TODO add your handling code here:
        //ImageCanvas canvas = new ImageCanvas();
        //JFileChooser chooser = new JFileChooser();
        if (chooser == null)     {
              chooser = new JFileChooser();
              canvas = new ImageCanvas();
              chooser.setDialogTitle("Images");
              chooser.setFileFilter(new ImageFilter());
              //orangePanel.add(chooser);
        chooser.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
                chooserOptionsActionPerformed(evt);
        setVisible(true);
        chooser.showOpenDialog(null);
    }//GEN-LAST:event_openMenuItemActionPerformed
    public class ImageFilter extends FileFilter {
        public boolean accept(File file) {
            if (file.toString().toLowerCase().endsWith("jpg")) {
                return true;
            return false;
        public String getDescription() {
            return "JPEG Files";
    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nextButtonActionPerformed
    private void previousButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previousButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_previousButtonActionPerformed
    private void zoomOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomOutButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_zoomOutButtonActionPerformed
    private void zoomInButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomInButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_zoomInButtonActionPerformed
    private void chooserOptionsActionPerformed(java.awt.event.ActionEvent evt)    {
        String command = evt.getActionCommand();
        if (command.equals(JFileChooser.APPROVE_SELECTION))   {
            System.out.println("open was pressed");
            File chosen = chooser.getSelectedFile();
                if (chosen != null && chosen.exists() && chosen.isFile()) {
                    try {
                        ImageIcon icon = new ImageIcon(chosen.toURL());
                        canvas.setImageIcon(icon);
                             getContentPane().validate();
                        setTitle(chosen.getName());
                    } catch (Exception e) {
                        setTitle(e.getLocalizedMessage());
        else if (command.equals(JFileChooser.CANCEL_SELECTION))   {
        //else {
            System.out.println("cancel was pressed");
            chooser.setEnabled(false);
    public class ImageCanvas extends JPanel {
        private ImageIcon imageIcon = null;
        private Dimension size = null;
        public ImageCanvas() {
            setBackground(Color.white);
        public void setImageIcon(ImageIcon icon) {
            this.imageIcon = icon;
            if (icon != null) {
                size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
            repaint();
        public ImageIcon getImageIcon() {
            return this.imageIcon;
        public void paint(Graphics g) {
            super.paint(g);
            if (imageIcon != null) {
                imageIcon.paintIcon(this, g, 0, 0);
        public Dimension getPreferredSize() {
            if (imageIcon == null) {
                return super.getPreferredSize();
            } else {
                return size;
    }Sorry for the code snippets.. I coudn't put the entire code since its too long (netbeans). some lines are just for printing

    1. For Swing components, the method to override is paintComponent, not paint.
    2. Why use ImageIcon when you can paint an Image?
    -- Load the image using ImageIO.read(File input)
    -- For the rest, go through The Java&#8482; Tutorials: [Performing Custom Painting|http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]
    db

  • Opening an .xls file and writing data to it....

    Hi ,
    I have written the following simple routine... which is supposed to open a .xls file and some data are written...:
    DECLARE
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheet ole2.obj_type;
    worksheets ole2.obj_type;
    cell ole2.obj_type;
    --Declare handles to OLE argument lists
    args ole2.list_type;
    BEGIN
    application:=OLE2.CREATE_OBJ('Excel.Application');
    OLE2.Set_Property(application,'Visible', 'True');
    workbooks := ole2.get_obj_property(application, 'Workbooks');
    workbook:=OLE2.INVOKE_OBJ(workbooks,'Add');
    args:= ole2.create_arglist;
    ole2.add_arg(args, 'c:\example.XLS');
    workbook := ole2.invoke_obj(workbook, 'Open', args);
    ole2.destroy_arglist(args);
    args:=OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 1); 
    OLE2.ADD_ARG(args, 1);
    cell:=OLE2.Invoke_Obj(workbooks, 'Cells', args); 
    OLE2.DESTROY_ARGLIST(args);
    OLE2.Set_Property(cell, 'Value', 'Excel');
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 0);
    OLE2.INVOKE(workbook, 'Close', args);
    OLE2.DESTROY_ARGLIST(args);
    OLE2.RELEASE_OBJ(cell);
    OLE2.RELEASE_OBJ(workbook);
    OLE2.RELEASE_OBJ(workbooks);
    OLE2.RELEASE_OBJ(application);
    OLE2.INVOKE(application,'Quit');
    END; but it does nothing.... it simply opens the Excel application..... How should I modify the routine in order to open the example.xls file and write some data to it .....???????
    Many thanks,
    Simon

    OK... I SOLVED THE PROBLEM.....
    Regards,
    Simon

  • Accessing a page in a tiled Tiff image file

    hi all
    I have a tiled tiff image file containing 10 images,please tell me how to process a specific image say 7th image using ordImage process method ,I am using oracle 8.1.7 and win 2000.
    regards
    Ravi Kiran

    Having multiple images in a tiff file is probably not the best practice. THe image object meta data might not make much sense (width, height, format...).
    But....
    For 8.1.7, there is no way to do it from PL/SQL. You could do it outside the database in a servlet.
    For 9i, there is an undocumented interface to allow for access to tiff images other than the first image that is being considered for documentation with 10i.

  • Loading a file and setting the values in a Jtextfield

    Hi all,
    I've created a save and open menu option for my application. The save option works as it writes to file using jFileChooser. However when using the open file option the program opens the correct file and stores the strings read into a string variable, however when I go to set the value stored in the variable to a specific textfield using settext method, it doesn't do anything. Please can someone give me some suggestions on what I am doing wrong. The following is the code snippet that accesses the file and reads from it:
    try
    int result = jFileChooser1.showOpenDialog(this);
    if ( result == JFileChooser.APPROVE_OPTION )
    String str1 = jFileChooser1.getCurrentDirectory() +
    System.getProperty("file.separator") + jFileChooser1.getSelectedFile().getName() ;
    FileReader f = new FileReader( str1 );
    BufferedReader b = new BufferedReader(f);
    while((text1 = b.readLine()) != null)
    //text2 = b.readLine();
    jTextArea1.append("\ntext1: "+text1+"\nsize: "+size);
    if(text1 == "// System Configuration")
    text1 = b.readLine();
    size = text1.length();
    //text2 = text1;
    jSampleRate.setText(text1);
    text1 = b.readLine();
    size = text1.length();
    //text2 = text1;
    jFrequency.setText(text1);
    text1 = b.readLine();
    size = text1.length();
    //text2 = text1;
    jVoltage.setText(text1);
    text1 = b.readLine();
    size = text1.length();
    text2 = text1;
    jFSVoltage1.setText(text1);
    /*if((text = b.readLine()) == "// Phase Selection")
    // READ INFORMATION LOOKING FOE THE SPECIFIC TAGS
    b.close();
    jFileChooser1.cancelSelection();
    Any suggestions wpould be very much appreciated. Thanks in advance.

    this is the result from the read in information:
    text1 is the string variable that is used to store the information read in from the file, while size is the variable used to obtian the size of the string. Does the readline() method have any properties which would affect what is being read in?
    text1: |=========================================================================================
    size: 0
    text1: | File Name: C:\CsoundTest\walid3
    size: 0
    text1: | Last Modified: 30-01-2003 11:25:11
    size: 0
    text1: | Warning: Do not modify the information stored in this file. If modified the inforamtion
    size: 0
    text1: | may not be retrieved correctly when loading the file into the main program.
    size: 0
    text1: |==========================================================================================
    size: 0
    text1:
    size: 0
    text1: // System Configuration
    size: 0
    text1: 500
    size: 0
    text1: 50
    size: 0
    text1: 230
    size: 0
    text1: 300
    size: 0
    text1:
    size: 0
    text1: // Phase Selection
    size: 0
    text1: 1VIncN
    size: 0
    text1:
    size: 0
    text1: // Duration
    size: 0
    text1: 0
    size: 0
    text1: 00
    size: 0
    text1: 00
    size: 0
    text1:
    size: 0
    text1: // Disturbances
    size: 0
    text1:
    size: 0
    Regards
    walidr

  • CS2 USED to open my raw files, and now it doesn't. HELP!

    This is probably addressed somewhere but Ive looked and have been unable to find an answer to my specific problem.
    I previously had an imac G5 with CS2. I purchased a new camera (Canon 5D) and the computer had no trouble opening and editing raw files. WEll...computer crashed, I bought a new computer, installed CS2 and low and behold, I no longer seem to have Camera Raw. Where did it go? No amount of downloading plugins will help, since I don't have it in the first place. I get an error message "Photoshop does not recognize this type of file" both when I try to open a RAW file AND when I try to install a camera raw plugin.
    I am so frustrated. I have piles of shoots to edit and I'm falling behind. PLEASE HELP.

    The Canon 5D needs ACR 3.3. A fresh installation of PS will have a lower version. You can confirm this by looking in PS Help > About Plug-in...
    You must download the latest 3.x version and install it exactly following the instructions.
    Get it here:http://www.adobe.com/support/downloads/detail.jsp?ftpID=3581

  • My x3 phone can't open any image file

    i updated my phone yestrday and after that, my phone cannot open any image files....it says 'no image to display'......now whats wrong with my phone????

    /t5/Xseries/Can-Someone-Help-me/td-p/712783
    Previous Phones: 6600, 7610, 6230, 6230i, 1100, 1112, N70, N73, N95, N95 8GB, 5800XM, 5230, C5, iPhone 3GS, SE Xperia X10, N900, N8, SE Xperia Arc
    Current Phones: Nokia N9, iPhone 4

  • Software to open McDraw image files

    Need Tiger 10.4.11 compatible software to open MacDraw image files created in 1985-88 period that were used in a book I authored.
    Appleworks cannot 'see' them. Any ideas short of tearing a book apart and scanning them.. which would preclude being able to alter them.

    http://www.purgatorydesign.com/Intaglio/
    http://www.eazydraw.com/
    Image files may also be opened by http://www.lemkesoft.com/ 's GraphicConverter if they are non-vector in origin.

  • Opening disk image files in Windows?

    Is there anything, free software or something like MacDrive (which I've never used) that will open disk image files, particularly encypted ones? I keep an encrypted disk image on my thumb drive with important information and I'd like to be able to open it in Windows. I recently came across the open-source TrueCrypt for Linux and Windows, but I would love some kind of software that would work on all three platforms, or at least OS X and Windows.
    Thanks,
    Alan

    PGP works on the Mac. They currently do not have a working version for intel based Macs. Your profile indicates you have a PowerMac so you should be good to go. Download the free trial and check it out.

  • Suddenly cannot open an image file

    PS 7 on a Vista machine with lots of RAM.
    All has been working well for months and suddenly I cannot open any image file or start a new one. Tried re-installing from OEM disc and no improvement. Removed PS7 VIA the Windows utility and re-installed entire application from OEM disc with still no improvement.
    When I try to open or start a new image the blue bar at the top of PS is illuminated, then I click on FILE and then on either NEW or OPEN. At that point everything stops. The drop down menus are grayed out and I cannot close the program by normal means. In order to close it I have to go to Task Manager and close the thing.
    BTW: Sometimes Task Manager shows that the PS EXE application is using 44K and other times it shows about 7K.
    Any suggestions will be happily recieved.  Jack

    I really hate to be a pain, but this has me stumped.
    I tried to go to the preferences as you suggested but the same thing happens there. PS just freezes up and cannot be used at all. Even the red X at the top right of the screeen does nothing. I have to use Task Manager in order to quit the program.
    I have removed PS from my machine VIA the Windows utility and reinstalled it several times with no improvement. I say that, but at one point I was able to open an image but when I tried to add another the system did the freeze up thing as above.
    At some point I began to get sort of an error message during the PS bootup telling me that the PS interface font could not be loaded and that I should reboot my machine. I did that but there has been no change.
    Frankly I cannot afford to buy time from Adobe to fix this so I am relying on you and the other folks on the board to hold my hand through this.
    I thank you for your time and expertise.
    Ralph

  • How to open an Excel file and write data into it.

    Hi All,
    I have an excel template, which has graphs and some tables containing corresponding data. If i change the data in tables it changes the graphs. So, if i have a template in the server, is it possible for me to open this excel file and change the data in the tables to chanage the graphs. How can i go to different worksheets and go to different cells and change the values and save the file.
    Thanx in advance
    Cheers
    Pej

    You can setup an ODBC connection to the Excel file and update the file with JDBC, using the JDBC-ODBC bridge.
    Hope this helps

Maybe you are looking for

  • Using Bootcamp for Windows XP Installation

    Forgive the irony of asking this question on an Apple forum. I'm planning to use Bootcamp to install Windows XP on my MBP. I have a legitimate WinXP SP2 license currently installed on a desktop PC that I plan to decommission. How do I deauthorize the

  • How do I delete alcoholsoft from firefox toolbar ?

    '''''''''bold text''' How can I delete Alcoholsoft app from firefox toolbar . I appeared a couple months ago and now there is nothing I can do to get rid of it !

  • I am have permission problems and need urgent help!

    I am running ppc G5 dual 2gig with Tiger 10.4.11. I must say that ever since I upgraded to this version from 10.4.10 my system somehow has been behaving poorly. Ist my network settings went weird in the fact that the PC (running XP service Pack 2) st

  • How to delete Transaction Codes

    Hi Everyone, How to delete the Transaction codes which appear in Transaction box which appear in the top left where we keen in the entries in ECC6. With Regards, Venkat

  • Toshiba Satellite won't go past Toshiba welcome screen.

    Hi. I have a Toshiba Satellite laptop that was shut while running and sat overnight without power so it was basically sleeping. In the morning, I turned it on and it froze on the Toshiba welcome screen which is the first thing you see when you start