[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Changing the Brightness of a bitmap image in a picturebox using VB.NET???

Christopher Secules

10/25/2004 5:22:00 PM

I've looked everywhere on how to change the brightness of an image in
VB.NET. I see that you can get the brightness of a pixel, but I can't find
any way to set the brightness of the pixel. I would think that a basic
function like this would've been included in VS.NET, since they seem to have
included everything else. Please, if anyone has any suggestions, I would be
very appreciative!!

Thanks,
Chris


6 Answers

Bob Powell

10/25/2004 11:37:00 PM

0

Changing the brightness is a matter of increasing the R, G and B componenets
uniformly.

Use a ColorMatrix and set the offsets accordingly. The ColorMartix to double
brightness would look like this:

1,0,0,0,0
0,1,0,0,0
0,0,1,0,0
0,0,0,1,0
2,2,2,0,1

See answers to the post entitled "Alphablend in .NET" for the ret of the
deal on setting up an ImageAttributes object.

Note that this method changes the brightness of the whole image. There is an
article in the GDI+ FAQ which details how to use HSB and RGB functions in
..NET if you need to change individual pixels.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob's Blog: http://bobpowelldotnet.blogspot.co...






"Christopher Secules" <secules@pica.army.mil> wrote in message
news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> I've looked everywhere on how to change the brightness of an image in
> VB.NET. I see that you can get the brightness of a pixel, but I can't
find
> any way to set the brightness of the pixel. I would think that a basic
> function like this would've been included in VS.NET, since they seem to
have
> included everything else. Please, if anyone has any suggestions, I would
be
> very appreciative!!
>
> Thanks,
> Chris
>
>


Christopher Secules

10/26/2004 2:55:00 PM

0

Bob,

My exact situation is this. I have a remote application that has a server
side and a client side. Most of the time, they are running on the same
machine, although they don't have to be. The server stores and loads the
bitmaps, and when the screen needs to change, it breaks the bitmap down into
a stream and the client picks it up and re-composes it to display it. It is
a very simple color scheme: Orange foreground, Black background. However,
the Server side could possibly get commands to (1). Increase Brightness,
(2). Decrease Brightness, or (3). Set Brightness to a different value. The
range for the Bright ness is 0-Fh (0-15). Can I do this with the
ColorMatrix?

I also took a look at the GDI+ FAQ, and found the HSL/RGB stuff to be
helpful. The main problem I see with both methods, however, is if you set
the Brightness to 0, you can't raise it back up again because 0*anything =
0. For this reason, do I offset all the values by 1?

Thanks for the info!

Chris


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:u1tMRuuuEHA.908@TK2MSFTNGP11.phx.gbl...
> Changing the brightness is a matter of increasing the R, G and B
componenets
> uniformly.
>
> Use a ColorMatrix and set the offsets accordingly. The ColorMartix to
double
> brightness would look like this:
>
> 1,0,0,0,0
> 0,1,0,0,0
> 0,0,1,0,0
> 0,0,0,1,0
> 2,2,2,0,1
>
> See answers to the post entitled "Alphablend in .NET" for the ret of the
> deal on setting up an ImageAttributes object.
>
> Note that this method changes the brightness of the whole image. There is
an
> article in the GDI+ FAQ which details how to use HSB and RGB functions in
> .NET if you need to change individual pixels.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdipl...
>
> The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
> Bob's Blog: http://bobpowelldotnet.blogspot.co...
>
>
>
>
>
>
> "Christopher Secules" <secules@pica.army.mil> wrote in message
> news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> > I've looked everywhere on how to change the brightness of an image in
> > VB.NET. I see that you can get the brightness of a pixel, but I can't
> find
> > any way to set the brightness of the pixel. I would think that a basic
> > function like this would've been included in VS.NET, since they seem to
> have
> > included everything else. Please, if anyone has any suggestions, I
would
> be
> > very appreciative!!
> >
> > Thanks,
> > Chris
> >
> >
>
>


Christopher Secules

10/26/2004 4:09:00 PM

0

Also, the image is getting displayed in a Picturebox. I'd like to redisplay
the image in the Picturebox after I'm done adjusting the brightness, if that
is at all possible. I've looked around online and thought I had an
understanding, but I think there is something fundamental that I'm missing,
since things are still not working correctly.

thanks


"Christopher Secules" <secules@pica.army.mil> wrote in message
news:OBBZRv2uEHA.1976@TK2MSFTNGP09.phx.gbl...
> Bob,
>
> My exact situation is this. I have a remote application that has a server
> side and a client side. Most of the time, they are running on the same
> machine, although they don't have to be. The server stores and loads the
> bitmaps, and when the screen needs to change, it breaks the bitmap down
into
> a stream and the client picks it up and re-composes it to display it. It
is
> a very simple color scheme: Orange foreground, Black background. However,
> the Server side could possibly get commands to (1). Increase Brightness,
> (2). Decrease Brightness, or (3). Set Brightness to a different value. The
> range for the Bright ness is 0-Fh (0-15). Can I do this with the
> ColorMatrix?
>
> I also took a look at the GDI+ FAQ, and found the HSL/RGB stuff to be
> helpful. The main problem I see with both methods, however, is if you set
> the Brightness to 0, you can't raise it back up again because 0*anything =
> 0. For this reason, do I offset all the values by 1?
>
> Thanks for the info!
>
> Chris
>
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:u1tMRuuuEHA.908@TK2MSFTNGP11.phx.gbl...
> > Changing the brightness is a matter of increasing the R, G and B
> componenets
> > uniformly.
> >
> > Use a ColorMatrix and set the offsets accordingly. The ColorMartix to
> double
> > brightness would look like this:
> >
> > 1,0,0,0,0
> > 0,1,0,0,0
> > 0,0,1,0,0
> > 0,0,0,1,0
> > 2,2,2,0,1
> >
> > See answers to the post entitled "Alphablend in .NET" for the ret of the
> > deal on setting up an ImageAttributes object.
> >
> > Note that this method changes the brightness of the whole image. There
is
> an
> > article in the GDI+ FAQ which details how to use HSB and RGB functions
in
> > .NET if you need to change individual pixels.
> >
> > --
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/gdipl...
> >
> > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > Windows Forms Tips and Tricks RSS:
http://www.bobpowell.net/tips...
> > Bob's Blog: http://bobpowelldotnet.blogspot.co...
> >
> >
> >
> >
> >
> >
> > "Christopher Secules" <secules@pica.army.mil> wrote in message
> > news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> > > I've looked everywhere on how to change the brightness of an image in
> > > VB.NET. I see that you can get the brightness of a pixel, but I can't
> > find
> > > any way to set the brightness of the pixel. I would think that a
basic
> > > function like this would've been included in VS.NET, since they seem
to
> > have
> > > included everything else. Please, if anyone has any suggestions, I
> would
> > be
> > > very appreciative!!
> > >
> > > Thanks,
> > > Chris
> > >
> > >
> >
> >
>
>


Bob Powell

10/26/2004 4:18:00 PM

0

I would reccommend not modifying the original image until the user was
satisfied with the result. Perhaps display both side-by-side so that they
can compare the original with the new one. This means that you'll never
modify the overall brightness of an image to 0 and then say "oops" and be
unable to put it back again.

To set the brightness in the range o-15 just use multiples of 1.0f / 15 as
the value in the offset.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob's Blog: http://bobpowelldotnet.blogspot.co...






"Christopher Secules" <secules@pica.army.mil> wrote in message
news:OBBZRv2uEHA.1976@TK2MSFTNGP09.phx.gbl...
> Bob,
>
> My exact situation is this. I have a remote application that has a server
> side and a client side. Most of the time, they are running on the same
> machine, although they don't have to be. The server stores and loads the
> bitmaps, and when the screen needs to change, it breaks the bitmap down
into
> a stream and the client picks it up and re-composes it to display it. It
is
> a very simple color scheme: Orange foreground, Black background. However,
> the Server side could possibly get commands to (1). Increase Brightness,
> (2). Decrease Brightness, or (3). Set Brightness to a different value. The
> range for the Bright ness is 0-Fh (0-15). Can I do this with the
> ColorMatrix?
>
> I also took a look at the GDI+ FAQ, and found the HSL/RGB stuff to be
> helpful. The main problem I see with both methods, however, is if you set
> the Brightness to 0, you can't raise it back up again because 0*anything =
> 0. For this reason, do I offset all the values by 1?
>
> Thanks for the info!
>
> Chris
>
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:u1tMRuuuEHA.908@TK2MSFTNGP11.phx.gbl...
> > Changing the brightness is a matter of increasing the R, G and B
> componenets
> > uniformly.
> >
> > Use a ColorMatrix and set the offsets accordingly. The ColorMartix to
> double
> > brightness would look like this:
> >
> > 1,0,0,0,0
> > 0,1,0,0,0
> > 0,0,1,0,0
> > 0,0,0,1,0
> > 2,2,2,0,1
> >
> > See answers to the post entitled "Alphablend in .NET" for the ret of the
> > deal on setting up an ImageAttributes object.
> >
> > Note that this method changes the brightness of the whole image. There
is
> an
> > article in the GDI+ FAQ which details how to use HSB and RGB functions
in
> > .NET if you need to change individual pixels.
> >
> > --
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/gdipl...
> >
> > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > Windows Forms Tips and Tricks RSS:
http://www.bobpowell.net/tips...
> > Bob's Blog: http://bobpowelldotnet.blogspot.co...
> >
> >
> >
> >
> >
> >
> > "Christopher Secules" <secules@pica.army.mil> wrote in message
> > news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> > > I've looked everywhere on how to change the brightness of an image in
> > > VB.NET. I see that you can get the brightness of a pixel, but I can't
> > find
> > > any way to set the brightness of the pixel. I would think that a
basic
> > > function like this would've been included in VS.NET, since they seem
to
> > have
> > > included everything else. Please, if anyone has any suggestions, I
> would
> > be
> > > very appreciative!!
> > >
> > > Thanks,
> > > Chris
> > >
> > >
> >
> >
>
>


Christopher Secules

10/26/2004 4:55:00 PM

0

I think I finally got the ColorMatrix thing figured out wrt to lightening
and darkening. Thank you very much for your help with that.

I have one more question, though. The nature of the display is what I
mentioned before; foreground = orange, background = black. I just realized
that I need to have the brightest setting to be all pixels orange, instead
of all white. Is there any way to accomplish this?

Thanks,
Chris


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:e28Zfd3uEHA.2564@TK2MSFTNGP12.phx.gbl...
> I would reccommend not modifying the original image until the user was
> satisfied with the result. Perhaps display both side-by-side so that they
> can compare the original with the new one. This means that you'll never
> modify the overall brightness of an image to 0 and then say "oops" and be
> unable to put it back again.
>
> To set the brightness in the range o-15 just use multiples of 1.0f / 15 as
> the value in the offset.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdipl...
>
> The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
> Bob's Blog: http://bobpowelldotnet.blogspot.co...
>
>
>
>
>
>
> "Christopher Secules" <secules@pica.army.mil> wrote in message
> news:OBBZRv2uEHA.1976@TK2MSFTNGP09.phx.gbl...
> > Bob,
> >
> > My exact situation is this. I have a remote application that has a
server
> > side and a client side. Most of the time, they are running on the same
> > machine, although they don't have to be. The server stores and loads the
> > bitmaps, and when the screen needs to change, it breaks the bitmap down
> into
> > a stream and the client picks it up and re-composes it to display it. It
> is
> > a very simple color scheme: Orange foreground, Black background.
However,
> > the Server side could possibly get commands to (1). Increase Brightness,
> > (2). Decrease Brightness, or (3). Set Brightness to a different value.
The
> > range for the Bright ness is 0-Fh (0-15). Can I do this with the
> > ColorMatrix?
> >
> > I also took a look at the GDI+ FAQ, and found the HSL/RGB stuff to be
> > helpful. The main problem I see with both methods, however, is if you
set
> > the Brightness to 0, you can't raise it back up again because 0*anything
=
> > 0. For this reason, do I offset all the values by 1?
> >
> > Thanks for the info!
> >
> > Chris
> >
> >
> > "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> > news:u1tMRuuuEHA.908@TK2MSFTNGP11.phx.gbl...
> > > Changing the brightness is a matter of increasing the R, G and B
> > componenets
> > > uniformly.
> > >
> > > Use a ColorMatrix and set the offsets accordingly. The ColorMartix to
> > double
> > > brightness would look like this:
> > >
> > > 1,0,0,0,0
> > > 0,1,0,0,0
> > > 0,0,1,0,0
> > > 0,0,0,1,0
> > > 2,2,2,0,1
> > >
> > > See answers to the post entitled "Alphablend in .NET" for the ret of
the
> > > deal on setting up an ImageAttributes object.
> > >
> > > Note that this method changes the brightness of the whole image. There
> is
> > an
> > > article in the GDI+ FAQ which details how to use HSB and RGB functions
> in
> > > .NET if you need to change individual pixels.
> > >
> > > --
> > > Bob Powell [MVP]
> > > Visual C#, System.Drawing
> > >
> > > Answer those GDI+ questions with the GDI+ FAQ
> > > http://www.bobpowell.net/gdipl...
> > >
> > > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > > Windows Forms Tips and Tricks RSS:
> http://www.bobpowell.net/tips...
> > > Bob's Blog: http://bobpowelldotnet.blogspot.co...
> > >
> > >
> > >
> > >
> > >
> > >
> > > "Christopher Secules" <secules@pica.army.mil> wrote in message
> > > news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> > > > I've looked everywhere on how to change the brightness of an image
in
> > > > VB.NET. I see that you can get the brightness of a pixel, but I
can't
> > > find
> > > > any way to set the brightness of the pixel. I would think that a
> basic
> > > > function like this would've been included in VS.NET, since they seem
> to
> > > have
> > > > included everything else. Please, if anyone has any suggestions, I
> > would
> > > be
> > > > very appreciative!!
> > > >
> > > > Thanks,
> > > > Chris
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Christopher Secules

10/26/2004 5:44:00 PM

0

I'm really sorry to keep changing this. The whole thing is actually
emulating an actual terminal, so I have to keep going back into the lab and
looking at different aspects of it.

Now I realized that the background isn't actually lightening or darkening;
if a pixel is black, it stays black. The orange foreground is what gets
brighter or dimmer. With this information, I'm guessing I can't do a
bitmap-wide lightening and darkening. I probably have to go pixel by pixel,
and if the color isn't black, then lighten or darken it. Does this mean I
have to use the HSL-RGB conversion method?

Thanks again for your help,
Chris


"Christopher Secules" <secules@pica.army.mil> wrote in message
news:egpyOy3uEHA.3948@TK2MSFTNGP15.phx.gbl...
> I think I finally got the ColorMatrix thing figured out wrt to lightening
> and darkening. Thank you very much for your help with that.
>
> I have one more question, though. The nature of the display is what I
> mentioned before; foreground = orange, background = black. I just
realized
> that I need to have the brightest setting to be all pixels orange, instead
> of all white. Is there any way to accomplish this?
>
> Thanks,
> Chris
>
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:e28Zfd3uEHA.2564@TK2MSFTNGP12.phx.gbl...
> > I would reccommend not modifying the original image until the user was
> > satisfied with the result. Perhaps display both side-by-side so that
they
> > can compare the original with the new one. This means that you'll never
> > modify the overall brightness of an image to 0 and then say "oops" and
be
> > unable to put it back again.
> >
> > To set the brightness in the range o-15 just use multiples of 1.0f / 15
as
> > the value in the offset.
> >
> > --
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/gdipl...
> >
> > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > Windows Forms Tips and Tricks RSS:
http://www.bobpowell.net/tips...
> > Bob's Blog: http://bobpowelldotnet.blogspot.co...
> >
> >
> >
> >
> >
> >
> > "Christopher Secules" <secules@pica.army.mil> wrote in message
> > news:OBBZRv2uEHA.1976@TK2MSFTNGP09.phx.gbl...
> > > Bob,
> > >
> > > My exact situation is this. I have a remote application that has a
> server
> > > side and a client side. Most of the time, they are running on the same
> > > machine, although they don't have to be. The server stores and loads
the
> > > bitmaps, and when the screen needs to change, it breaks the bitmap
down
> > into
> > > a stream and the client picks it up and re-composes it to display it.
It
> > is
> > > a very simple color scheme: Orange foreground, Black background.
> However,
> > > the Server side could possibly get commands to (1). Increase
Brightness,
> > > (2). Decrease Brightness, or (3). Set Brightness to a different value.
> The
> > > range for the Bright ness is 0-Fh (0-15). Can I do this with the
> > > ColorMatrix?
> > >
> > > I also took a look at the GDI+ FAQ, and found the HSL/RGB stuff to be
> > > helpful. The main problem I see with both methods, however, is if you
> set
> > > the Brightness to 0, you can't raise it back up again because
0*anything
> =
> > > 0. For this reason, do I offset all the values by 1?
> > >
> > > Thanks for the info!
> > >
> > > Chris
> > >
> > >
> > > "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> > > news:u1tMRuuuEHA.908@TK2MSFTNGP11.phx.gbl...
> > > > Changing the brightness is a matter of increasing the R, G and B
> > > componenets
> > > > uniformly.
> > > >
> > > > Use a ColorMatrix and set the offsets accordingly. The ColorMartix
to
> > > double
> > > > brightness would look like this:
> > > >
> > > > 1,0,0,0,0
> > > > 0,1,0,0,0
> > > > 0,0,1,0,0
> > > > 0,0,0,1,0
> > > > 2,2,2,0,1
> > > >
> > > > See answers to the post entitled "Alphablend in .NET" for the ret of
> the
> > > > deal on setting up an ImageAttributes object.
> > > >
> > > > Note that this method changes the brightness of the whole image.
There
> > is
> > > an
> > > > article in the GDI+ FAQ which details how to use HSB and RGB
functions
> > in
> > > > .NET if you need to change individual pixels.
> > > >
> > > > --
> > > > Bob Powell [MVP]
> > > > Visual C#, System.Drawing
> > > >
> > > > Answer those GDI+ questions with the GDI+ FAQ
> > > > http://www.bobpowell.net/gdipl...
> > > >
> > > > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > > > Windows Forms Tips and Tricks RSS:
> > http://www.bobpowell.net/tips...
> > > > Bob's Blog: http://bobpowelldotnet.blogspot.co...
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > "Christopher Secules" <secules@pica.army.mil> wrote in message
> > > > news:e5v5ycruEHA.1860@TK2MSFTNGP15.phx.gbl...
> > > > > I've looked everywhere on how to change the brightness of an image
> in
> > > > > VB.NET. I see that you can get the brightness of a pixel, but I
> can't
> > > > find
> > > > > any way to set the brightness of the pixel. I would think that a
> > basic
> > > > > function like this would've been included in VS.NET, since they
seem
> > to
> > > > have
> > > > > included everything else. Please, if anyone has any suggestions,
I
> > > would
> > > > be
> > > > > very appreciative!!
> > > > >
> > > > > Thanks,
> > > > > Chris
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>