CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Brightness

  1. #1
    Join Date
    Feb 2007
    Posts
    59

    Brightness

    Hi i have a problem executing a loop to change the brightness of an image

    i have all the colour pixels and everytime the trackerbar moves it will decrease the pixels by 1 - i need to do this from 0 to 255 and vice a versa

    can anyone help?

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,153

    Re: Brightness


    Can you post your code so we might be able to help you.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Feb 2007
    Posts
    59

    Re: Brightness

    this is what i have soo far

    Code:
      ProgressBar1->Min = 0;
      ProgressBar1->Max = imgImage->Picture->Bitmap->Height;
    
      for (int y=0; y < imgImage->Picture->Bitmap->Height; y++)
      {
        for (int x=0; x < imgImage->Picture->Bitmap->Width; x++)
        {
           // Array index in pascal form
           Pixel.Colours = imgImage->Canvas->Pixels[x][y];
           Pixel.Channel.Red = 255;
           Pixel.Channel.Green = 255;
           Pixel.Channel.Blue = 255;
           imgImage->Canvas->Pixels[x][y] = Pixel.Colours;
        }
        ProgressBar1->Position = y;
      }
    
      imgImage->Repaint();
      ProgressBar1->Position = 0;
    }
    Last edited by sara666; March 21st, 2007 at 08:08 AM.

  4. #4
    Join Date
    Aug 2001
    Location
    Sydney, Australia
    Posts
    813

    Re: Brightness

    si = gi + brightness

    si is the grayscale value of the brightness enhanced image pixel and gi is the original image grayscale pixel value.

    Have fun
    Microsoft LVP - Least Valuable Professional

    Please rate this post... Pleeeeeeaaassee!!!

  5. #5
    Join Date
    Feb 2007
    Posts
    59

    Re: Brightness

    well i have tried working on it and have come up with a loop that changes the pixel value when the trackbar is moved

    Code:
     for (int y=0; y < Bitmap->Height; y++)
      {
    
        for (int x=0; x < Bitmap->Width; x++)
        {
          ImagePixels->Red = TrackBar2->Position;
          ImagePixels->Green = TrackBar2->Position;
          ImagePixels->Blue = TrackBar2->Position;
          ImagePixels++ ;
        }
      }
    
    imgImage->Repaint();
    but when i look at it i realise im just setting it not continues if you know what i mean

    how can i change it so that it will work?

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: Brightness

    Re-read Deniz's post

    You need to add/subtract, not just assign.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)