Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

convert this c sharp code in c++

aansaaansa Member Posts: 11
private void btn_convert_Click(object sender, EventArgs e)
{
Bitmap grays = (Bitmap)pb_color.Image;
int width = grays.Size.Width;
int height = grays.Size.Height;
for (int j = 0; j < height; j++)
{

for (int i = 0; i < width; i++)
{

Color col;
col = grays.GetPixel(i, j);
grays.SetPixel(i, j, Color.FromArgb((col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3));
}

}
pb_grayscale.Image = grays;
}

Comments

  • aansaaansa Member Posts: 11
    Bitmap ^grays = gcnew Bitmap(pictureBox1->Image);
    int width = grays->Size.Width;
    int height = grays->Size.Height;
    for (int j = 0; j < height; j++)
    {

    for (int i = 0; i < width; i++)
    {

    Color col;
    col = grays->GetPixel(i, j);
    grays->SetPixel(i, j, Color::FromArgb((col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3));

    }

    }
    pb_grayscale->Image = grays;

  • aansaaansa Member Posts: 11
    Bitmap ^grays = gcnew Bitmap(pictureBox1->Image);
    int width = grays->Size.Width;
    int height = grays->Size.Height;
    for (int j = 0; j < height; j++)
    {

    for (int i = 0; i < width; i++)
    {

    Color col;
    col = grays->GetPixel(i, j);
    grays->SetPixel(i, j, Color::FromArgb((col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3));

    }

    }
    pb_grayscale->Image = grays;

  • aansaaansa Member Posts: 11
    Bitmap ^grays = gcnew Bitmap(pictureBox1->Image);
    int width = grays->Size.Width;
    int height = grays->Size.Height;
    for (int j = 0; j < height; j++)
    {

    for (int i = 0; i < width; i++)
    {

    Color col;
    col = grays->GetPixel(i, j);
    grays->SetPixel(i, j, Color::FromArgb((col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3, (col.R + col.G + col.B) / 3));

    }

    }
    pb_grayscale->Image = grays;

Sign In or Register to comment.