Newsgroup: it.comp.lang.visual-basic
Titolo: Schiarire una parte di un'immagine

Come fare a rendere più chiara, più luminosa, una parte di un'immagine 
caricata in una picture box ?
So dell'esistenza dell'API SetColorAdjustment ma non ho trovato come 
utilizzare correttamente questa istruzione.
Dimenticavo: uso ancora il VB6 !
Grazie per l'attenzione
AlpVir 

 wrote:
Prova con questa classe:
Private Const RGB_GAMMA_MIN         As Long = 2500
Private Const RGB_GAMMA_MAX         As Long = 65000
Private Const REFERENCE_WHITE_MIN   As Long = 6000
Private Const REFERENCE_WHITE_MAX   As Long = 10000
Private Const REFERENCE_BLACK_MIN   As Long = 0
Private Const REFERENCE_BLACK_MAX   As Long = 4000
Private Const COLOR_ADJ_MIN         As Long = -100
Private Const COLOR_ADJ_MAX         As Long = 100
Public Enum enColourAdjustFlags
    CA_NEGATIVE = &H1
    CA_LOG_FILTER = &H2
End Enum
Public Enum enIlluninantIndexes
    ILLUMINANT_DEVICE_DEFAULT = 0
    ILLUMINANT_TUNGSTEN = 1
    ILLUMINANT_NOON_SUNLIGHT = 2
    ILLUMINANT_NTSC_DAYLIGHT = 3
    ILLUMINANT_NORMAL_PRINT = 4
    ILLUMINANT_BOND_PRINT = 5
    ILLUMINANT_STANDARD_DAYLIGHT = 6
    ILLUMINANT_NORTHEN_DAYLIGHT = 7
    ILLUMINANT_FLOURESCENT_LIGHT = 8
End Enum
Private 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
Private Declare Function GetColorAdjustment Lib "gdi32" (ByVal hdc As
Long, lpca As COLORADJUSTMENT) As Long
Private Declare Function SetColorAdjustment Lib "gdi32" (ByVal hdc As
Long, lpca As COLORADJUSTMENT) As Long
Private mParentDC As Long, mColourAdjustment As COLORADJUSTMENT
Public Property Set ParentDC(ByVal newDC As ApiDeviceContext)
    If newDC.hdc <> mParentDC Then
        mParentDC = newDC.hdc
        GetColorAdjustment mParentDC, mColourAdjustment
        If Err.LastDllError > 0 Then ReportError Err.LastDllError,
"ApiColourAdjustment:ParentDC", APIDispenser.LastSystemError
    End If
End Property
Private Function RefreshColourAdjustment()
    If mParentDC > 0 Then
        SetColorAdjustment mParentDC, mColourAdjustment
        If Err.LastDllError > 0 Then ReportError Err.LastDllError,
"ApiColourAdjustment:RefreshColourAdjustment",
APIDispenser.LastSystemError
    End If
End Function
Public Property Get Brightness() As Integer
    Brightness = mColourAdjustment.caBrightness
End Property
Public Property Let Brightness(ByVal newValue As Integer)
    newValue = IIf(newValue < COLOR_ADJ_MIN, COLOR_ADJ_MIN,
COLOR_ADJ_MAX)
    If newValue <> mColourAdjustment.caBrightness Then
        mColourAdjustment.caBrightness = newValue
        RefreshColourAdjustment
    End If
End Property
Public Property Get Contrast() As Integer
    Contrast = mColourAdjustment.caContrast
End Property
Public Property Let Contrast(ByVal newContrast As Integer)
    newContrast = IIf(newContrast < COLOR_ADJ_MIN, COLOR_ADJ_MIN,
COLOR_ADJ_MAX)
    If newContrast <> mColourAdjustment.caContrast Then
        mColourAdjustment.caContrast = newContrast
        RefreshColourAdjustment
    End If
End Property
Public Property Get Colourfulness() As Integer
    Colourfulness = mColourAdjustment.caColorfulness
End Property
Public Property Let Colourfulness(ByVal newValue As Integer)
    newValue = IIf(newValue < COLOR_ADJ_MIN, COLOR_ADJ_MIN,
COLOR_ADJ_MAX)
    If newValue <> mColourAdjustment.caColorfulness Then
        mColourAdjustment.caColorfulness = newValue
        RefreshColourAdjustment
    End If
End Property
Public Property Get IlluminantIndex() As enIlluninantIndexes
    IlluminantIndex = mColourAdjustment.caIlluminantIndex
End Property
Public Property Let IlluminantIndex(ByVal newIndex As
enIlluninantIndexes)
    If mColourAdjustment.caIlluminantIndex <> newIndex Then
        mColourAdjustment.caIlluminantIndex = newIndex
        RefreshColourAdjustment
    End If
End Property
Public Property Get RedGreenTint() As Integer
    RedGreenTint = mColourAdjustment.caRedGreenTint
End Property
Public Property Let RedGreenTint(ByVal newTint As Integer)
    newTint = IIf(newTint < COLOR_ADJ_MIN, COLOR_ADJ_MIN,
COLOR_ADJ_MAX)
    If newTint <> mColourAdjustment.caRedGreenTint Then
        mColourAdjustment.caRedGreenTint = newTint
        RefreshColourAdjustment
    End If
End Property
Public Property Get RedGamma() As Integer
    RedGamma = mColourAdjustment.caRedGamma
End Property
Public Property Let RedGamma(ByVal newGamma As Integer)
    newGamma = IIf(newGamma < RGB_GAMMA_MIN, RGB_GAMMA_MIN,
RGB_GAMMA_MAX)
    If mColourAdjustment.caRedGamma <> newGamma Then
       mColourAdjustment.caRedGamma = newGamma
       RefreshColourAdjustment
    End If
End Property
Public Property Get GreenGamma() As Integer
    GreenGamma = mColourAdjustment.caGreenGamma
End Property
Public Property Let GreenGamma(ByVal newGamma As Integer)
    newGamma = IIf(newGamma < RGB_GAMMA_MIN, RGB_GAMMA_MIN,
RGB_GAMMA_MAX)
    If mColourAdjustment.caGreenGamma <> newGamma Then
       mColourAdjustment.caGreenGamma = newGamma
       RefreshColourAdjustment
    End If
End Property
Public Property Get BlueGamma() As Integer
    BlueGamma = mColourAdjustment.caBlueGamma
End Property
Public Property Let BlueGamma(ByVal newGamma As Integer)
    newGamma = IIf(newGamma < RGB_GAMMA_MIN, RGB_GAMMA_MIN,
RGB_GAMMA_MAX)
    If mColourAdjustment.caBlueGamma <> newGamma Then
       mColourAdjustment.caBlueGamma = newGamma
       RefreshColourAdjustment
    End If
End Property



A me sembra pero' che il codice da te proposto intervenga su *tutta* 
l'immagine e non su una porzione di essa (ad esempio una striscia in basso).
Potrei in ogni caso avere un esempio di utilizzo ?
Grazie comunque.
AlpVir 

Dimenticavo: una soluzione che preveda l'esame di ogni singolo pixel sarebbe 
impraticabile. L'immagine da schiarire parzialmente è di circa 5000x800 
pixel e si dovrebbe intervenire su 5000x120 pixel circa.
Una soluzione cioè del tipo :
        For Y = 10 To pic1.ScaleHeight - 1
            For X = 0 To pic1.ScaleWidth - 1
                UnRGB pic1.Point(X, Y), R, G, B
                R = R + (255 - R) * fraction
                G = G + (255 - G) * fraction
                B = B + (255 - B) * fraction
                pic2.PSet (X, Y), RGB(R, G, B)
            Next X
        Next Y