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 8330293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:04:56+00:00 2026-06-09T02:04:56+00:00

I have a simple file that reads in a monochrome bitmap (i.e. black and

  • 0

I have a simple file that reads in a monochrome bitmap (i.e. black and white) and prints out x’s to represent the black portion. However, I noticed that for some reason I need to add the code

img.RotateFlip(RotateFlipType.Rotate270FlipY);

for it to show up “normally.” In other words, it seems that something in either my code or the implementation of the built-in functions is rotating and flipping the image as it’s read in, acting counter to what I intend.

I’m betting on this is a silly mistake more than “working as intended,” so I’m including the relevant code below:

    private void button1_Click(object sender, EventArgs e)
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            // Stream objects for capturing image data
            StreamReader sr = new StreamReader(openFileDialog1.OpenFile());
            MemoryStream memStream = new MemoryStream();

            // Image objects containing image data
            Bitmap img = (Bitmap) Bitmap.FromStream(sr.BaseStream);


            /**** HACK ****/
            //img.RotateFlip(RotateFlipType.Rotate270FlipY);
            /****      ****/


            // Save the image data to our memory stream
            img.Save(memStream, ImageFormat.Gif);

            // Save data to a byte array
            byte[] imgData = memStream.ToArray();

            // Print image data
            for (int x = 0; x < img.Width; ++x)
            {
                Color rgb = new Color();
                for (int y = 0; y < img.Height; ++y)
                {
                    rgb = img.GetPixel(x, y);

                    if (rgb.ToArgb().Equals(Color.White.ToArgb()))
                    {
                       textBox1.AppendText(" ");
                    }
                    else
                    {
                        textBox1.AppendText("x");
                    }
                }
                textBox1.AppendText(Environment.NewLine);
            }
        }
    }

I read in a bitmap of the letter ‘B’ and it gives me the following.

Without the “hack”:

     x                         x        
     x                         x        
     x                         x        
     xx                       xx        
     xxxxxxxxxxxxxxxxxxxxxxxxxxx        
     xxxxxxxxxxxxxxxxxxxxxxxxxxx        
     xxxxxxxxxxxxxxxxxxxxxxxxxxx        
     x            x            x        
     x            x            x        
     x            x            x        
     x            x            x        
     x            x            x        
     x            x            x        
     x            x            x        
     x            x            x        
                  x            x        
      x          xx                     
      x         xxxx          x         
      xx       xxx x          x         
       xx     xxxx xx        xx         
       xxxxxxxxxx   xxx    xxx          
         xxxxxxx    xxxxxxxxxx          
           xxx       xxxxxxx            
                       xxx              

With the “hack”:

     xxxxxxxxxxxxxxx                   
        xxxx         xxx               
         xxx           xxx             
         xxx            xx             
         xxx             xx            
         xxx             xx            
         xxx             xxx           
         xxx             xxx           
         xxx             xxx           
         xxx            xxx            
         xxx           xxxx            
         xxx          xxxx             
         xxx         xxxx              
         xxxxxxxxxxxxxx                
         xxx          xxx              
         xxx            xxx            
         xxx             xxx           
         xxx             xxx           
         xxx              xxx          
         xxx              xxx          
         xxx              xxx          
         xxx              xx           
         xxx             xxx           
         xxx             xx            
         xxx            xxx            
        xxxx          xxx              
     xxxxxxxxxxxxxxxx                  

I very much look forward to having my mistake pointed out to me. 🙂

Thanks in advance!

  • 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-09T02:04:57+00:00Added an answer on June 9, 2026 at 2:04 am

    Your problem is that you’re building rows with your inner loop to put into the text box, but your inner loop loops over y. Try changing the nesting of those loops, and see what you get. Also, your y loop needs to start at the top, or the image will be upside down.

        for (int y = img.Height - 1; y >= 0; --y)
        {
            Color rgb = new Color();
            for (int x = 0; x < img.Width; ++x)
            {
                rgb = img.GetPixel(x, y);
    
                if (rgb.ToArgb().Equals(Color.White.ToArgb()))
                {
                   textBox1.AppendText(" ");
                }
                else
                {
                    textBox1.AppendText("x");
                }
            }
            textBox1.AppendText(Environment.NewLine);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a very simple script that reads out a txt file, puts the
I have a simple java code that reads text csv file that contains sentences
I have a simple script of code that reads a PHP file and when
I have a map that reads an XML file; it's all very simple and
I have a simple C# Console App that reads in an XML file specified
I have a simple Java program that reads in a text file, splits it
I have a simple code that looks up a text file, reads the line
I have a simple problem that reads an Excel file (using interop) and fills
I have the following simple code, that reads contents of a text file into
I have a Perl script that reads a simple .csv file like below- header1,header2,header3,header4

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.