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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:06:37+00:00 2026-06-05T17:06:37+00:00

Possible Duplicate: Fast way to convert a Bitmap into a Boolean array in C#?

  • 0

Possible Duplicate:
Fast way to convert a Bitmap into a Boolean array in C#?

in my project I have a resource that is a black and white bitmap which I’m using to hold some 4×4 black and white sprites. Before I can use this data effectively though I need to convert it to a 2D multidimensional (or jagged, doesn’t matter) boolean array, with false representing white and black representing true.

Here is my current solution:

    public Bitmap PiecesBitmap = Project.Properties.Resources.pieces;
    bool[,] PiecesBoolArray = new bool[4, 16]; // 4 wide, 16 high (4 4x4 images)

    for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 16; y++)
                {
                    if (PiecesBitmap.GetPixel(x, y) == Color.Black)
                    {
                        PiecesBoolArray[x, y] = true;
                    }
                    else
                    {
                        PiecesBoolArray[x, y] = false;
                    }

                }
            }

Since I will be calling this function a lot (with different bitmaps), is there a more efficient way of doing this? .GetPixel is kind of slow, and it just feels like I’m missing out on some trick here. Thank you for any suggestions.

  • 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-05T17:06:38+00:00Added an answer on June 5, 2026 at 5:06 pm

    Use Bitmap.LockBits. You’ll find tutorials on the web.

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

Sidebar

Related Questions

Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: Compute fast log base 2 ceiling What is the fastest possible way
Possible Duplicate: PHP validation/regex for URL Is there any easy, secure and fast way
Possible Duplicate: Element-wise array replication in Matlab I have a m x 1 vector
Possible Duplicate: Counting the swaps required to convert one permutation into another I'm looking
Possible Duplicate: C++ Error: free(): invalid next size (fast): That's a C++ question (albeit
Possible Duplicate: Does fast enumeration in Objective-C guarantee the order of iteration? Just a
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: What is considered fast performance for a single server request? I'm building
Possible Duplicate: Why does C# execute Math.Sqrt() more slowly than VB.NET? I'm running into

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.