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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:36:14+00:00 2026-05-28T06:36:14+00:00

How do I make this into a grayscale? After much googling it seems the

  • 0

How do I make this into a grayscale?

After much googling it seems the best I can do is change the tint of the picture (in the code bellow, it’s a green tint). How can I do it?

byte[] redGreenBlueVal = new byte[numBytes];

for (int i = 0; i < redGreenBlueVal .Length; i += 4)
{
    redGreenBlueVal [i + 0] = (byte)(.114 * redGreenBlueVal [i + 0]); --> blue
    redGreenBlueVal [i + 1] = (byte)(.587 * redGreenBlueVal [i + 1]); --> green
    redGreenBlueVal [i + 2] = (byte)(.299 * redGreenBlueVal [i + 2]); --> red
}
  • 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-05-28T06:36:15+00:00Added an answer on May 28, 2026 at 6:36 am

    In effect you’re adjusting HSB so this should get you a better grayscale image:
    30% RED
    59% GREEN
    11% BLUE

    byte[] redGreenBlueVal = new byte[numBytes];
    
    for (int i = 0; i < redGreenBlueVal .Length; i += 4)
    {
          gray = (byte)(.11 * redGreenBlueVal [i + 0]);
          gray += (byte)(.59 * redGreenBlueVal [i + 1]); 
          gray += (byte)(.3 * redGreenBlueVal [i + 2]);
    
          redGreenBlueVal [i + 0] = gray;
          redGreenBlueVal [i + 1] = gray;
          redGreenBlueVal [i + 2] = gray;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me make this query loop into an efficient Linq query? I
I don't want to make this into a which is better... MVC or WebForms
I need to make this design: http://www.stephburningham.com/lmg/ into a joomla template but I've never
Before I get into the details of this problem, I'd like to make the
To make this more clear, I'm going to put code samples: $file = fopen('filename.ext',
How can I make this work? switch(property.PropertyType){ case typeof(Boolean): //doStuff break; case typeof(String): //doOtherStuff
How can I make this java generic cast ? public interface IField { }
alt text http://img202.imageshack.us/img202/2637/dialogo.png I'm wondering how I could make this into a popup dialog.
I have this code, which I would like to make as small as possible.
How can I convert a 2D array of ints into a grayscale png. right

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.