Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

inverser couleur

2 réponses
Avatar
Geko
Bonjour,

J'arrive =E0 inverser les couleurs d'un picture Box suite =E0=20
un printscreen. Le probl=E8me est lorsque je fais=20
printer.PaintPicture picture1.picture,0,0 c'est=20
l'original du printscreen qui s'imprime et non avec les=20
couleurs invers=E9es, pourtant je vois bien que les=20
couleurs sont invers=E9es dans mon picture1. Aidez-moi je=20
sais plus...

Sub Invert(picBox As PictureBox)
'Invert the image of a picturebox
Dim newVal As Integer, h As Integer, W As Integer, K As=20
Integer
Dim C As Long
Dim opRed As Long, opBlue As Long, opGreen As Long

picBox.ScaleMode =3D 3

For h =3D 0 To picBox.ScaleHeight
For W =3D 0 To picBox.ScaleWidth

C =3D GetPixel(picBox.hdc, W, h)
RGBfromLONG C
opRed =3D 255 - rRed
opGreen =3D 255 - rGreen
opBlue =3D 255 - rBlue
C =3D RGB(opRed, opGreen, opBlue)
SetPixel picBox.hdc, W, h, C
Next W
Next h
End Sub

2 réponses

Avatar
François Picalausa
"Geko" a écrit dans le message de
news:098601c3c962$23a6ae50$
Bonjour,

J'arrive à inverser les couleurs d'un picture Box suite à
un printscreen. Le problème est lorsque je fais
printer.PaintPicture picture1.picture,0,0 c'est
l'original du printscreen qui s'imprime et non avec les
couleurs inversées, pourtant je vois bien que les
couleurs sont inversées dans mon picture1. Aidez-moi je
sais plus...



Bonjour/soir,

Essaye Picture1.Image au lieu de Picture1.Picture

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
Avatar
Zoury
Salut Geko! :O)

Essai ce code à la place du tient, c'est beaucoup plus performant..
'***
' Form1
' 2 PictureBoxes
Option Explicit

Private Declare Function BitBlt _
Lib "gdi32" _
( _
ByVal hDestDC 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 dwRop As Long _
) As Long

Private Sub Command1_Click()
Picture2.BackColor = vbWhite
Call BitBlt(Picture2.hDC, 0, 0, Picture1.ScaleWidth,
Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcInvert)
End Sub

Private Sub Form_Load()
Set Picture1.Picture = LoadPicture("C:Documents and
SettingsYanick.lefebvreMy DocumentsMy Received
Filesyanick_halloween.jpg")
End Sub
'***

ps : Change le chemin de l'image pour qu'il pointe vers la tienne..

--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/
http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/

Merci de poster les réponses au groupe afin d'en faire profiter à tous