Convertendo in Vb.Net:
Risultato ottenuto utilizzando l'utility su http://authors.aspalliance.com/aldot...translate.aspxcodice:Public Shared Function Brightness(b As Bitmap, nBrightness As Integer) As Boolean ' LUMINOSITA' (richiede il parametro della luminosità compreso tra -255 e 255) ' eseguo il controllo dell'intervallo -255/255 If nBrightness < - 255 Or nBrightness > 255 Then Return False End If ' stessi commenti della funzione INVERT per quanto riguarda le inizializzazioni Dim bmData As BitmapData = b.LockBits(New Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb) Dim stride As Integer = bmData.Stride Dim Scan0 As System.IntPtr = bmData.Scan0 ' variabile nVal = 0 che sarà usata per contenere la somma del colore con la luminosità Dim nVal As Integer = 0 ' 'ToDo: Error processing original source shown below ' ' '-^--- expression expected If (True) Then Dim p As Machine.BytePtr = New Machine.BytePtr(Machine.BytePtr.Cast(Machine.TypePtr.Cast(Scan0, GetType()))) ' 'ToDo: Error processing original source shown below ' ' '---------------------^--- GenCode(token): unexpected token type Dim nOffset As Integer = stride - b.Width * 3 Dim nWidth As Integer = b.Width * 3 Dim y As Integer While y < b.Height Dim x As Integer While x < nWidth ' nVal = componente RGB + parametro luminosità nVal = CInt(p(0) + nBrightness) ' controllo che nVal sia compreso tra 0 e 255 (componente RGB) If nVal < 0 Then nVal = 0 End If If nVal > 255 Then nVal = 255 End If ' riassegno alla componente RGB il nuovo valore p(0) = CByte(nVal) End While ' incremento il puntatore alla componente successiva ' incremento alla riga successiva p = p.PtrForOffset(nOffset) End While End If b.UnlockBits(bmData) Return True End Function 'Brightness
Vedi se ti possono essere d'aiuto i risultati e gli errori mostrati.
![]()

Rispondi quotando