Besoin d'aide et vite si possible !!!

CaptainChoc Messages postés 35 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 20 juin 2006 - 28 mars 2002 à 22:15
CaptainChoc Messages postés 35 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 20 juin 2006 - 31 mars 2002 à 22:55
Voilà le code source, jessaye d'enregistrer le picture3 (voir source) car quand je fait savepicture, il bug. Merci d'avance
il necessite 3 picture box et une listbox avec 6 choix dans la list.

code source:

Private Sub MERGE(INVERTED1 As Boolean, INVERTED2 As Boolean)
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer

Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'on regarde les valeurs RGB de la première image
GET_COLORS Picture1.Point(X, y), R1, G1, B1, INVERTED1
'on regarde les valeurs RGB de la seconde image
GET_COLORS Picture2.Point(X, y), R2, G2, B2, INVERTED2

Picture3.PSet (X, y), RGB((R1 + R2) / 2, (G2 + G1) / 2, (B2 + B1) / 2)
Next y
Next X
Beep
End Sub
------------------------------------------------------
Private Sub NEGATIVE_IMAGE(PICTURE As PictureBox)
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer

Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'on regarde les valeurs RGB de l'image
GET_COLORS PICTURE.Point(X, y), R1, G1, B1, True

Picture3.PSet (X, y), RGB(R1, G1, B1)
Next y
Next X
End Sub

--------------------------------------------------------
Private Sub GET_COLORS(COLOR As Long, ByRef R As Integer, ByRef G As Integer, ByRef B As Integer, INVERTED As Boolean)

'Ici on regarde les valeurs du RGB
Dim TEMP As Long
TEMP = (COLOR And 255)
R = TEMP And 255
TEMP = Int(COLOR / 256)
G = TEMP And 255
TEMP = Int(COLOR / 65536)
B = TEMP And 255

If INVERTED = True Then
R = Abs(R - 255)
G = Abs(G - 255)
B = Abs(B - 255)
End If
End Sub

Private Sub Form_Load()

End Sub
-------------------------------------------------
Private Sub List1_DblClick()

Select Case List1.ListIndex
Case 0:
MERGE False, False
Case 1:
MERGE True, False
Case 2:
MERGE False, True
Case 3:
MERGE True, True
Case 4:
NEGATIVE_IMAGE Picture1
Case 5:
NEGATIVE_IMAGE Picture2
End Select
End Sub

2 réponses

TFlorian Messages postés 194 Date d'inscription dimanche 3 mars 2002 Statut Membre Dernière intervention 19 décembre 2005 3
30 mars 2002 à 15:09
Bonjour ,
Je te propose une solution :
Tu a cent doute remarque que suit tu reduit la fenetre et que tu l'agrandi l'image disparait !
pour cela il y a une propriete a definir pour que windows redessine l'image lor de la restoration de l'image ::
' Active la propriété AutoRedraw.
AutoRedraw = True

De plus pour aller BEAUCOUP plus vite dans le tretement de tes image tu peut utiliser une echelle un pixel : le tres gros aventage est que tu gere en 1024*768 1024 points en horisontal et 768 en vertical contre respectivement 14760*10920 en TWIP (echel par defaul dans les projet VB)
' Définit l'échelle en pixels.
ScaleMode = vbPixels

Voici ton prog modifier par mes soins :
pour enregistere l'image DBclick sur le font de la form
l'image est alors enregistree sous c:\TEST.BMP

Private Sub MERGE(INVERTED1 As Boolean, INVERTED2 As Boolean)
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer

Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'on regarde les valeurs RGB de la première image
GET_COLORS Picture1.Point(X, y), R1, G1, B1, INVERTED1
'on regarde les valeurs RGB de la seconde image
GET_COLORS Picture2.Point(X, y), R2, G2, B2, INVERTED2

PSet (X, y), RGB((R1 + R2) / 2, (G2 + G1) / 2, (B2 + B1) / 2)
Next y
Next X
Beep
End Sub

Private Sub NEGATIVE_IMAGE(PICTURE As PictureBox)
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer

Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'on regarde les valeurs RGB de l'image
GET_COLORS PICTURE.Point(X, y), R1, G1, B1, True

PSet (X, y), RGB(R1, G1, B1)
Next y
Next X
End Sub

Private Sub GET_COLORS(COLOR As Long, ByRef R As Integer, ByRef G As Integer, ByRef B As Integer, INVERTED As Boolean)

'Ici on regarde les valeurs du RGB
Dim TEMP As Long
TEMP = (COLOR And 255)
R = TEMP And 255
TEMP = Int(COLOR / 256)
G = TEMP And 255
TEMP = Int(COLOR / 65536)
B = TEMP And 255

If INVERTED = True Then
R = Abs(R - 255)
G = Abs(G - 255)
B = Abs(B - 255)
End If
End Sub

Private Sub Form_DblClick()
'ini on sauve l'image !
SavePicture Image, "c:\TEST.BMP"
MsgBox "Image sauvee dans" & vbCrLf & App.Path
End Sub

Private Sub Form_Load()
' Définit l'échelle en pixels.
ScaleMode = vbPixels
' Active la propriété AutoRedraw.
AutoRedraw = True

' Définit l'échelle en pixels.
Picture1.PICTURE ScaleMode = vbPixels
' Active la propriété AutoRedraw.
Picture1.PICTURE AutoRedraw = True

' Définit l'échelle en pixels.
Picture2.PICTURE ScaleMode = vbPixels
' Active la propriété AutoRedraw.
Picture2.PICTURE AutoRedraw = True

' Définit l'échelle en pixels.
Picture3.PICTURE ScaleMode = vbPixels
' Active la propriété AutoRedraw.
Picture3.PICTURE AutoRedraw = True

End Sub

Private Sub List1_DblClick()

Select Case List1.ListIndex
Case 0:
MERGE False, False
Case 1:
MERGE True, False
Case 2:
MERGE False, True
Case 3:
MERGE True, True
Case 4:
NEGATIVE_IMAGE Picture1
Case 5:
NEGATIVE_IMAGE Picture2
End Select

End Sub

Voila
(tu peut peut etre travailler sur une autre form pour exoter tes images ...

TFlorian.
0
CaptainChoc Messages postés 35 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 20 juin 2006
31 mars 2002 à 22:55
Merci tu me sauve la vie......(lol)
Nan franchement, c impec, ca marche......merci
0
Rejoignez-nous