Results 1 to 5 of 5

Thread: Contrast / Brightness in .BMP file.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134
    Does anyone know how to change Contrast / Brightness in .BMP file loaded into a picturebox ?

    Or any site where I can learn it (I've searched it in VB Web Directory, VB Square, VB Api, this site and more) ?

    Thanks in advance,

    Jorge Ledo
    [email protected]
    Portugal were the sun allways shine... for programmers.

  2. #2
    Guest
    Try planet-source-code.com

    It's full of all different kinds of source code.

    [Edited by Megatron on 03-31-2000 at 04:14 PM]

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Keep this updated, I may solve my problem with crossfading images, if I only know a way to darken the images first and then use AND bitcomparation.

    Thanks!

  4. #4
    Lively Member
    Join Date
    May 2000
    Posts
    84

    Smile COLORADJUSTMENT

    'Ok I have one solution to adjust brigtness and contrast of 'a picture box. First make the following API declarations:
    -----------------------------------------------------------
    Public Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

    Public Declare Function SetStretchBltMode Lib "gdi32" Alias "SetStretchBltMode" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long

    Public Declare Function SetColorAdjustment Lib "gdi32" Alias "SetColorAdjustment" (ByVal hdc As Long, lpca As COLORADJUSTMENT) As Long
    -----------------------------------------------------------
    'Now create the following structure and desinate a vairable 'to it call something like ColorInfo
    -----------------------------------------------------------
    Public Type COLORADJUSTMENT
    caSize As Integer
    caFlags As Integer
    caIlluminantIndex As Integer
    caRedGamma As Integer
    caGreenGamma As Integer
    caBlueGamma As Integer
    caReferenceBlack As Integer
    caReferenceWhite As Integer
    caContrast As Integer
    caBrightness As Integer
    caColorfulness As Integer
    caRedGreenTint As Integer
    End Type

    Public Const HALFTONE = 4

    Global ColorInfo as COLORADJUSTMENT

    -----------------------------------------------------------
    'On your form load procedure call the SetStretchBltMode

    SetStrecthBltMode Picture1.hdc, HALFTONE

    -----------------------------------------------------------
    To cause a change you modify the stteings of ColorInfo such as caBrightness and caContrast in a range from -100 to 100

    -----------------------------------------------------------
    'here a code section that will increase the brightness by 10
    'The brighness is increase 10
    'The SetColorAdjustment is called
    'An image is taken frim Picture2 and copyed to picture1 'with the changes in brightness made

    ColorInfo.caBrightness = ColorInfo.caBrightness + 10
    SetColorAdjustment Picture1.hdc, ColorInfo
    StretchBlt Picture1.hdc, 0, 0, Picture1.Width,_ Picture1.Height, Picture2.hdc, 0, 0, Picture2.Width,_ Picture2.Height, SRCCOPY

    'Note the StretBlt function can also be used for zoom 'functions and you can even adjust rgb tints with the ColorAdjustment structure

    -----------------------------------------------------------
    Now the only problem with this code is that it is too slow for decent animation and you always have to use HALFTONE as the palette mode... This doesnt cause to much trouble with high colors settings ie ..16 or 32 bit however with 256 colormode this function is almost useless.

  5. #5
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    The other problem with using that code is that it ONLY works in Windows NT (not even 2000).
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

Posting Permissions

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



Click Here to Expand Forum to Full Width