how can I open this geo tiff file into an image control RRS feed

  • Question

  • I'm trying to get started with using some geo tif files and found lib tiff. I've seen examples as to how to analyze the pixels and the tiff fields, but nothing that actually puts the internal image into a UI control so I can see it. There's still a bunch more for me to do, but I'd like to get this simple step out of the way.

    Here's what I've found so far:

    Tiff t = Tiff.Open("Images/ENR_L22.tif", "r");
    // Find the width and height of the image
    FieldValue[] value = t.GetField(TiffTag.IMAGEWIDTH);
    int width = value[0].ToInt();
    value = t.GetField(TiffTag.IMAGELENGTH);
    int height = value[0].ToInt();
    int imageSize = height * width;
    int[] raster = new int[imageSize];
    t.ReadRGBAImage(width, height, raster); // say, what?

    Michael DiLeo

    Tuesday, June 18, 2013 6:33 PM


All replies

  • Is there a reason you are using a 3rd party library instead of the Windows controls? You will need to ask for help on that library wherever you got it from.

    If you want to use the Windows BitmapDecoder then take a look at How to decode an image

    This previous thread specifically targets TIFFs: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/05994370-f21f-474b-acbd-65cb906b05df/split-a-tif-into-jpg-using-metro-ui


    Tuesday, June 18, 2013 11:38 PM
  • Thx!! I just gotta check to see if it supports tag fields or whatever for geo location info. Appreciate the help!

    Gah! Unfortunately every link I'm finding references older ways to open the files that don't apply in windows 8. still looking!

    Michael DiLeo

    • Edited by mcd023 Wednesday, June 19, 2013 3:06 PM update
    Wednesday, June 19, 2013 1:29 AM
  • Well so far, I've tried this, but got an out of memory exception. The original tiff image is 15MB with geoLoc data.

    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Images/ENR_L22.tif"));
     var stream = await file.OpenAsync(FileAccessMode.Read);
     var bitmapImage = new BitmapImage();
     await bitmapImage.SetSourceAsync(stream);
     Image im = new Image() { Source = bitmapImage };

    Michael DiLeo

    Wednesday, June 19, 2013 3:35 PM
  • How big is the image?

    Can you successfully decode it with a BitmapDecoder? If it is very large you may want to apply a transform to scale it down to something appropriate for the screen.


    Thursday, June 20, 2013 2:03 AM