Bitmap Brightness/Darkness 
Author Message
 Bitmap Brightness/Darkness

How can i do to Bightness/Darkness in the Bitmap using API calls?

thanx
Anderson Fonseca



Mon, 02 Jun 2003 23:12:23 GMT  
 Bitmap Brightness/Darkness

Quote:
> How can i do to Bightness/Darkness in the Bitmap using API calls?

Brightness/darkness is simply an offset on each pixel.  Depending on how
fast you want to perform this adjustment there are various things you can
do, if your only calling it once for a small image then just use the Get/Set
pixel routines.  Grab the PixLib module off my site, then step thought the
image using something like:

'*** (Untested)

Add declares for GetPixel() and SetPixelV() API functions.

Dim DarkenAmt As Integer
Dim ScanX As Integer, ScanY As Integer

DarkenAmt = 20 'Darken each chanel by 20 (Not very much, each chanel has a
range of 0 to 255)

For ScanX = 0 To Picture1.ScaleWidth
    For ScanY = 0 To Picture1.ScaleHeight
        'Grab the long colour value, convert it to a pixel type, darken it
by DarkenAmt, convert the new colour back to a long and draw.
        SetPixelV Picture1.hDC, ScanX, ScanY,
PixToLong(DarkenPix(LongToPix(GetPixel(Picture1.hDC, ScanX, ScanY)),
DarkenAmt))
    Next ScanY
Next Scanx

'***

If you need more speed then you'll need to do the image processing via a
DIB, you can still use my library to do the work, just change the routine to
use a value out of the array the DIB routines spit back rather than using
Get/Set pixel.  If your going to do this I recommend you convert the Pixel
UDT to 32-Bit, saves some headaches with Get/Set DIBits.
If you need more speed still then you can use a simple lookup, just
pre-calculate the new values in a 0 to 255 lookup table with the DarkenPix()
routine then fire each pixel at the lookup table.  This is VERY fast, but
quite complicated.
Similarly if you need to lighten the value then use the LightenPix()
function in place DarkenPix().
Hope this helps,

    Mike

 -- EDais --

WWW: Http://Members.xoom.com/EDais/




Tue, 03 Jun 2003 02:29:38 GMT  
 Bitmap Brightness/Darkness

Quote:
> How can i do to Bightness/Darkness in the Bitmap using API calls?

Brightness/darkness is simply an offset on each pixel.  Depending on how
fast you want to perform this adjustment there are various things you can
do, if your only calling it once for a small image then just use the Get/Set
pixel routines.  Grab the PixLib module off my site, then step thought the
image using something like:

'*** (Untested)

Add declares for GetPixel() and SetPixelV() API functions.

Dim DarkenAmt As Integer
Dim ScanX As Integer, ScanY As Integer

DarkenAmt = 20 'Darken each chanel by 20 (Not very much, each chanel has a
range of 0 to 255)

For ScanX = 0 To Picture1.ScaleWidth
    For ScanY = 0 To Picture1.ScaleHeight
        'Grab the long colour value, convert it to a pixel type, darken it
by DarkenAmt, convert the new colour back to a long and draw.
        SetPixelV Picture1.hDC, ScanX, ScanY,
PixToLong(DarkenPix(LongToPix(GetPixel(Picture1.hDC, ScanX, ScanY)),
DarkenAmt))
    Next ScanY
Next Scanx

'***

If you need more speed then you'll need to do the image processing via a
DIB, you can still use my library to do the work, just change the routine to
use a value out of the array the DIB routines spit back rather than using
Get/Set pixel.  If your going to do this I recommend you convert the Pixel
UDT to 32-Bit, saves some headaches with Get/Set DIBits.
If you need more speed still then you can use a simple lookup, just
pre-calculate the new values in a 0 to 255 lookup table with the DarkenPix()
routine then fire each pixel at the lookup table.  This is VERY fast, but
quite complicated.
Similarly if you need to lighten the value then use the LightenPix()
function in place DarkenPix().
Hope this helps,

    Mike

 -- EDais --

WWW: Http://Members.xoom.com/EDais/




Tue, 03 Jun 2003 02:29:38 GMT  
 Bitmap Brightness/Darkness

Quote:
> How can i do to Bightness/Darkness in the Bitmap using API calls?

Brightness/darkness is simply an offset on each pixel.  Depending on how
fast you want to perform this adjustment there are various things you can
do, if your only calling it once for a small image then just use the Get/Set
pixel routines.  Grab the PixLib module off my site, then step thought the
image using something like:

'*** (Untested)

Add declares for GetPixel() and SetPixelV() API functions.

Dim DarkenAmt As Integer
Dim ScanX As Integer, ScanY As Integer

DarkenAmt = 20 'Darken each chanel by 20 (Not very much, each chanel has a
range of 0 to 255)

For ScanX = 0 To Picture1.ScaleWidth
    For ScanY = 0 To Picture1.ScaleHeight
        'Grab the long colour value, convert it to a pixel type, darken it
by DarkenAmt, convert the new colour back to a long and draw.
        SetPixelV Picture1.hDC, ScanX, ScanY,
PixToLong(DarkenPix(LongToPix(GetPixel(Picture1.hDC, ScanX, ScanY)),
DarkenAmt))
    Next ScanY
Next Scanx

'***

If you need more speed then you'll need to do the image processing via a
DIB, you can still use my library to do the work, just change the routine to
use a value out of the array the DIB routines spit back rather than using
Get/Set pixel.  If your going to do this I recommend you convert the Pixel
UDT to 32-Bit, saves some headaches with Get/Set DIBits.
If you need more speed still then you can use a simple lookup, just
pre-calculate the new values in a 0 to 255 lookup table with the DarkenPix()
routine then fire each pixel at the lookup table.  This is VERY fast, but
quite complicated.
Similarly if you need to lighten the value then use the LightenPix()
function in place DarkenPix().
Hope this helps,

    Mike

 -- EDais --

WWW: Http://Members.xoom.com/EDais/




Tue, 03 Jun 2003 02:29:38 GMT  
 Bitmap Brightness/Darkness
Sorry for the multiple posts, my ISP has problems..

    Mike

 -- EDais --

WWW: Http://Members.xoom.com/EDais/




Tue, 03 Jun 2003 11:03:32 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Brightness control of bitmap in picturebox

2. Changing Bitmap Brightness in Hi-Color

3. changing bitmap brightness in hi-color mode

4. Bitmap brightness

5. Changing contrast and brightness on a bitmap

6. Controlling contrast, color and brightness?

7. Changing Brightness in ActiveMovie (WMP ActiveX)

8. Brightness control

9. change brightness of picture

10. Setting monitor brightness through code?

11. Brightness control

12. Brightness and Contrast - Plea for help !!!

 

 
Powered by phpBB® Forum Software