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

  • Home
  • SEARCH
  • 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 8408847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:44:40+00:00 2026-06-09T23:44:40+00:00

This is my first post here and I’m fairly desperate. My issue is that

  • 0

This is my first post here and I’m fairly desperate.

My issue is that I’m supposed to make a game for a client (more of a friend favour type of thing so no pay 🙁 but meh jobs a job and I said I could do it, build rep and all that)

im using XNA 4 and therefore C#.

Now I need to figure out a way to count pixels of a certain colour, black to be specific. That’s it.
I have drawn a bunch of sprites and they are NOT of black. Some of them are UI but they are all at the side of the screen so I should be able to ignore those pixels right?

I figured I should be able to read the buffers once I have made all my draw calls. But I just can’t find any internet stuff (that’s readable) that tells me whether or not that’s even possible.
Read is the colour of the pixels I’m interested in is all I need to do. Lets say everything from width 50 to the edge of the window for example.

C# and XNA 4 answers are what i need.
whether you give me the answer on a silver platter or point me in the direction of something that will tell me how to do the various parts of it.

As a programmer goes I still count as a noob, just… a trained noob, so i might ask stupid questions to your excellent answers 🙂

  • 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-09T23:44:41+00:00Added an answer on June 9, 2026 at 11:44 pm

    You should be able to use GraphicsDevice.ResolveBackBuffer()
    to copy the screen to a ResolveTexture2D. Then you can use Texture2D.GetData() to store the texture’s color data in a Color[] array.

    ResolveTexture2D texture = new ResolveTexture2D(
        graphics.GraphicsDevice,
        graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
        graphics.GraphicsDevice.PresentationParameters.BackBufferHeight,
        1,
        graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);
    
    Color[] colorData = new Color[texture.Width * texture.Height];
    texture.GetData<Color>(colorData);
    

    From there you should be able to do your thing to count the colors while ignoring edge pixels.

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

Sidebar

Related Questions

this is my first post here! I'm trying to make a windows forms program
This is my first post here, and i should advise that my knowledge is
This is my first post on here.. I'm writing a program in MVC3 that
This is my first post here so kindly pardon any mistakes that I have.
This is my first post here and I hope that someone will be able
This is my first post here, and I'm fairly new to Qt. I am
This is my first post here so go easy. I am trying to build
This is my first post here. I have a problem. I need to take
this is my first post here on stackoverflow and am very impressed by the
My first post here, so i hope this is the right area. I am

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.