Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:10:03+00:00 2026-06-06T04:10:03+00:00

i am in trouble. how to read 1MB .tif file with bitmap class in

  • 0

i am in trouble. how to read 1MB .tif file with bitmap class in c#. i used below code but getting error “Out of memory”.I searched google lot but not find any answer yet.

string imgPath;
            imgPath = @"C:\Documents and Settings\shree\Desktop\2012.06.09.15.35.42.2320.tif";
            Image newImage = Image.FromFile(imgPath);

            Bitmap img;
            img = new Bitmap(imgPath, true);

            MessageBox.Show("Width: "+ img.Width + " Height: " + img.Height);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:10:05+00:00Added an answer on June 6, 2026 at 4:10 am

    If you just need to read the width and height of the file without loading it in memory you could use WPF’s BitmapDecoder class:

    using System;
    using System.IO;
    using System.Linq;
    using System.Windows.Media.Imaging;
    
    class Program
    {
        static void Main()
        {
            using (var stream = File.OpenRead(@"c:\work\some_huge_image.tif"))
            {
                var decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
                var frame = decoder.Frames.First();
                Console.WriteLine(
                    "width: {0}, height: {1}", 
                    frame.PixelWidth, 
                    frame.PixelHeight
                );
            }
        }
    }
    

    If for some reason you are stuck in some pre-.NET 3.0 era you could look at the image metadata to extract this information without loading the entire image in memory as shown in the following answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am in trouble. how to read 1MB .tif file with bitmap class in
I am having trouble passing data read from a text file to another class
I have to read data from mdb-files using c++ but I'm having trouble getting
I'm having trouble getting my program to read this XML file properly, it will
I've read a lot a blogs and forums but I'm still having trouble getting
I am having trouble to read a file containing lines like the one below
I'm having a bit of trouble getting my program to read in data from
I am in a real trouble here to read a large txt file (around
I've read through much of the ARM documentation but still having trouble decoding a
I'm having trouble with isdigit. I read the documentation, but when I cout <<

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.