Accueil > > > OBTENIR RGB PIXEL
OBTENIR RGB PIXEL
Information sur la source
Description
Bonsoir, C'est simplement un tooltip qui 'suit' le curseur de la souris et qui indique la couleur, sous la forme RGB, du pixel se trouvant sous le curseur. Le projet en C est fourni pour que vous puissiez suivre si vous ne comprenez pas tout.
Source
- .386
- .model flat, stdcall
- option casemap:none
-
- include \masm32\include\windows.inc
- include \masm32\include\user32.inc
- include \masm32\include\kernel32.inc
- ;include \masm32\include\masm32.inc
- include \masm32\include\comctl32.inc
- include \masm32\include\gdi32.inc
-
- includelib \masm32\lib\user32.lib
- includelib \masm32\lib\kernel32.lib
- ;includelib \masm32\lib\masm32.lib
- includelib \masm32\lib\comctl32.lib
- includelib \masm32\lib\gdi32.lib
-
- .data
-
- hInst dd 0
- htt dd 0
- iWidthScreen dd 0
- TOOLTIPS_CLASS db "tooltips_class32", 0
- szRGB db 256 dup(0)
-
- .code
-
- start:
- call InitCommonControls
- push 0
- call GetModuleHandle
- mov hInst, eax
- push 512
- push GPTR
- call GlobalAlloc
- push eax ;Param pour GlobalFree
- mov edx, WS_POPUP
- or edx, WS_CAPTION
- or edx, WS_SYSMENU
- xor ecx, ecx
- mov [eax], edx ; style
- mov word ptr[eax + 10], 0 ; x et y
- mov word ptr[eax + 12], 0
- mov word ptr[eax + 14], 50 ; cx et cy
- mov word ptr[eax + 16], 50
- mov edx, hInst
- push ecx
- push offset DlgProc
- push ecx
- push eax
- push edx
- call DialogBoxIndirectParam
- call GlobalFree
- push 0
- call ExitProcess
-
- DlgProc PROC
- mov eax, [esp + 8]
- cmp eax, WM_INITDIALOG
- je onDialog
- cmp eax, WM_COMMAND
- je onCmd
- cmp eax, WM_NOTIFY
- je onNotify
- cmp eax, WM_TIMER
- je onTimer
- jmp Fin
- ;ESP => hwnd (HWND) 4 octets
- ;ESP + 4 => htt (HWND) 4 octets
- ;ESP + 8 => ti (TOOLINFO) 44 octets
- onDialog:
- mov eax, offset szRGB
- mov dword ptr[eax], 28424752h ;'RGB('
- mov ecx, [esp + 4] ;hwnd
- lea eax, [esp - 48]
- mov esp, eax
- mov [eax], ecx
- xor eax, eax
- push eax
- mov edx, hInst
- push edx
- push eax
- push ecx
- push CW_USEDEFAULT
- push CW_USEDEFAULT
- push CW_USEDEFAULT
- push CW_USEDEFAULT
- mov edx, WS_POPUP
- or edx, TTS_NOPREFIX
- or edx, TTS_ALWAYSTIP
- push edx
- push eax
- push offset TOOLTIPS_CLASS
- push WS_EX_TOPMOST
- call CreateWindowEx
- test eax, eax
- je FinOnDialog
- mov htt, eax
- lea ecx, [esp + 4]
- mov dword ptr[ecx], 44 ;ti.cbSize
- mov edx, TTF_IDISHWND
- or edx, TTF_TRACK
- or edx, TTF_ABSOLUTE
- mov [ecx + 4], edx ;ti.uFlags
- mov [ecx + 12], eax ;ti.uID
- mov edx, hInst
- mov [ecx + 32], edx ;ti.hInst
- mov edx, [ecx - 4] ;hwnd (handle de la fenetre)
- mov [ecx + 8], edx ;ti.hwnd
- mov dword ptr[ecx + 36], LPSTR_TEXTCALLBACK ;ti.lpsztext
- push 0
- push 10
- push 1712
- push edx ;SetTimer
- push ecx
- push 1
- push TTM_TRACKACTIVATE
- push eax ;2eme SendMessage
- push ecx
- push 0
- push TTM_ADDTOOL
- push eax ;1er SendMessage
- call SendMessage
- call SendMessage
- call SetTimer
- push SM_CXSCREEN
- call GetSystemMetrics
- mov iWidthScreen, eax
- FinOnDialog:
- add esp, 48
- mov eax, 1
- ret 16
- ;ESP => hwnd (HWND) 4 octets
- ;ESP + 4 => pt (POINT) 8 octets
- ;ESP + 12 => hdcScr (HDC) 4 octets
- ;ESP + 16 => clrPixel (COLORREF)4 octets
- ;ESP + 20 => szRGB (char *) 20 octets
- onTimer:
- mov eax, [esp + 4]
- lea ecx, [esp - 40]
- mov esp, ecx
- mov [ecx], eax ;sauve hwnd
- lea eax, [ecx + 4]
- push eax
- call GetCursorPos
- push 0
- call GetDC
- lea ecx, [esp + 4]
- mov [ecx + 8], eax ;sauve hdcScr
- push [ecx + 4]
- push [ecx]
- push eax
- call GetPixel
- lea ecx, [esp]
- mov [ecx + 16], eax ;sauve clrPixel
- mov edx, [ecx + 12] ;hdcScr
- mov eax, [ecx] ;hwnd
- push edx
- push eax
- call ReleaseDC
- ;'Creation' chaine szRGB
- lea edx, [esp + 16] ;clrPixel
- movzx eax, byte ptr[edx]; GetRValue
- mov ecx, offset szRGB
- add ecx, 4 ;saute 'RGB('
- call ultoa
- mov byte ptr[eax], ','
- add eax, 1
- lea edx, [esp + 16]
- mov ecx, eax
- movzx eax, byte ptr[edx + 1] ;GetGValue
- call ultoa
- mov byte ptr[eax], ','
- add eax, 1
- lea edx, [esp + 16]
- mov ecx, eax
- movzx eax, byte ptr[edx + 2] ;GetBValue
- call ultoa
- mov byte ptr[eax], ')'
- add eax, 1
- mov byte ptr[eax], 0
- lea eax, [esp + 4]
- mov ecx, [eax] ;pt.x
- mov edx, [eax + 4] ;pt.y
- add ecx, 110
- cmp ecx, iWidthScreen
- jg Sub210
- sub ecx, 100
- jmp MakeLParam
- Sub210:
- sub ecx, 210
- MakeLParam:
- mov eax, edx
- shl eax, 16
- or eax, ecx
- mov edx, htt
- push eax
- push 0
- push TTM_TRACKPOSITION
- push edx
- call SendMessage
- xor eax, eax
- add esp, 40
- ret 16
- onCmd:
- mov eax, [esp + 12]
- cmp eax, IDCANCEL
- jne Fin
- mov ecx, [esp + 4]
- push 0
- push ecx ;hwnd pour EndDialog
- push 1712
- push ecx
- call KillTimer
- call EndDialog
- xor eax, eax
- ret 16
- onNotify:
- mov eax, [esp + 16] ; eax == lparam
- mov ecx, [eax + 8] ; ecx == lparam->code
- cmp ecx, TTN_GETDISPINFO
- jne Fin
- mov [eax + 12], offset szRGB
- Fin:
- xor eax, eax
- ret 16
- DlgProc ENDP
-
- ;FONCTION BRUNEWS
- ultoa PROC ; IN:EAX=dwNbr, ECX=lpsz
- test eax, eax
- jnz short L1
- lea eax, [ecx+1]
- mov byte ptr[ecx], 48
- mov byte ptr[eax], 0
- ret 0
- L1:
- mov [esp-4], edi
- mov [esp-8], ecx
- mov edi, ecx
- mov ecx, eax
- L2:
- mov eax, -858993459
- mul ecx
- mov eax, edx
- shr eax, 3
- mov edx, ecx
- lea ecx, [eax+eax*8]
- add ecx, eax
- sub edx, ecx
- add dl, 48
- mov [edi], dl
- mov ecx, eax
- inc edi
- test eax, eax
- jnz short L2
- mov [esp-12], edi
- mov eax, [esp-8]
- mov byte ptr[edi], 0
- L3:
- dec edi
- mov dl, [eax]
- mov cl, [edi]
- mov [edi], dl
- mov [eax], cl
- inc eax
- cmp eax, edi
- jb short L3
- mov eax, [esp-12]
- mov edi, [esp-4]
- ret 0
- ultoa ENDP
-
- END start
-
-
-
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
;include \masm32\include\masm32.inc
include \masm32\include\comctl32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
;includelib \masm32\lib\masm32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\gdi32.lib
.data
hInst dd 0
htt dd 0
iWidthScreen dd 0
TOOLTIPS_CLASS db "tooltips_class32", 0
szRGB db 256 dup(0)
.code
start:
call InitCommonControls
push 0
call GetModuleHandle
mov hInst, eax
push 512
push GPTR
call GlobalAlloc
push eax ;Param pour GlobalFree
mov edx, WS_POPUP
or edx, WS_CAPTION
or edx, WS_SYSMENU
xor ecx, ecx
mov [eax], edx ; style
mov word ptr[eax + 10], 0 ; x et y
mov word ptr[eax + 12], 0
mov word ptr[eax + 14], 50 ; cx et cy
mov word ptr[eax + 16], 50
mov edx, hInst
push ecx
push offset DlgProc
push ecx
push eax
push edx
call DialogBoxIndirectParam
call GlobalFree
push 0
call ExitProcess
DlgProc PROC
mov eax, [esp + 8]
cmp eax, WM_INITDIALOG
je onDialog
cmp eax, WM_COMMAND
je onCmd
cmp eax, WM_NOTIFY
je onNotify
cmp eax, WM_TIMER
je onTimer
jmp Fin
;ESP => hwnd (HWND) 4 octets
;ESP + 4 => htt (HWND) 4 octets
;ESP + 8 => ti (TOOLINFO) 44 octets
onDialog:
mov eax, offset szRGB
mov dword ptr[eax], 28424752h ;'RGB('
mov ecx, [esp + 4] ;hwnd
lea eax, [esp - 48]
mov esp, eax
mov [eax], ecx
xor eax, eax
push eax
mov edx, hInst
push edx
push eax
push ecx
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
mov edx, WS_POPUP
or edx, TTS_NOPREFIX
or edx, TTS_ALWAYSTIP
push edx
push eax
push offset TOOLTIPS_CLASS
push WS_EX_TOPMOST
call CreateWindowEx
test eax, eax
je FinOnDialog
mov htt, eax
lea ecx, [esp + 4]
mov dword ptr[ecx], 44 ;ti.cbSize
mov edx, TTF_IDISHWND
or edx, TTF_TRACK
or edx, TTF_ABSOLUTE
mov [ecx + 4], edx ;ti.uFlags
mov [ecx + 12], eax ;ti.uID
mov edx, hInst
mov [ecx + 32], edx ;ti.hInst
mov edx, [ecx - 4] ;hwnd (handle de la fenetre)
mov [ecx + 8], edx ;ti.hwnd
mov dword ptr[ecx + 36], LPSTR_TEXTCALLBACK ;ti.lpsztext
push 0
push 10
push 1712
push edx ;SetTimer
push ecx
push 1
push TTM_TRACKACTIVATE
push eax ;2eme SendMessage
push ecx
push 0
push TTM_ADDTOOL
push eax ;1er SendMessage
call SendMessage
call SendMessage
call SetTimer
push SM_CXSCREEN
call GetSystemMetrics
mov iWidthScreen, eax
FinOnDialog:
add esp, 48
mov eax, 1
ret 16
;ESP => hwnd (HWND) 4 octets
;ESP + 4 => pt (POINT) 8 octets
;ESP + 12 => hdcScr (HDC) 4 octets
;ESP + 16 => clrPixel (COLORREF)4 octets
;ESP + 20 => szRGB (char *) 20 octets
onTimer:
mov eax, [esp + 4]
lea ecx, [esp - 40]
mov esp, ecx
mov [ecx], eax ;sauve hwnd
lea eax, [ecx + 4]
push eax
call GetCursorPos
push 0
call GetDC
lea ecx, [esp + 4]
mov [ecx + 8], eax ;sauve hdcScr
push [ecx + 4]
push [ecx]
push eax
call GetPixel
lea ecx, [esp]
mov [ecx + 16], eax ;sauve clrPixel
mov edx, [ecx + 12] ;hdcScr
mov eax, [ecx] ;hwnd
push edx
push eax
call ReleaseDC
;'Creation' chaine szRGB
lea edx, [esp + 16] ;clrPixel
movzx eax, byte ptr[edx]; GetRValue
mov ecx, offset szRGB
add ecx, 4 ;saute 'RGB('
call ultoa
mov byte ptr[eax], ','
add eax, 1
lea edx, [esp + 16]
mov ecx, eax
movzx eax, byte ptr[edx + 1] ;GetGValue
call ultoa
mov byte ptr[eax], ','
add eax, 1
lea edx, [esp + 16]
mov ecx, eax
movzx eax, byte ptr[edx + 2] ;GetBValue
call ultoa
mov byte ptr[eax], ')'
add eax, 1
mov byte ptr[eax], 0
lea eax, [esp + 4]
mov ecx, [eax] ;pt.x
mov edx, [eax + 4] ;pt.y
add ecx, 110
cmp ecx, iWidthScreen
jg Sub210
sub ecx, 100
jmp MakeLParam
Sub210:
sub ecx, 210
MakeLParam:
mov eax, edx
shl eax, 16
or eax, ecx
mov edx, htt
push eax
push 0
push TTM_TRACKPOSITION
push edx
call SendMessage
xor eax, eax
add esp, 40
ret 16
onCmd:
mov eax, [esp + 12]
cmp eax, IDCANCEL
jne Fin
mov ecx, [esp + 4]
push 0
push ecx ;hwnd pour EndDialog
push 1712
push ecx
call KillTimer
call EndDialog
xor eax, eax
ret 16
onNotify:
mov eax, [esp + 16] ; eax == lparam
mov ecx, [eax + 8] ; ecx == lparam->code
cmp ecx, TTN_GETDISPINFO
jne Fin
mov [eax + 12], offset szRGB
Fin:
xor eax, eax
ret 16
DlgProc ENDP
;FONCTION BRUNEWS
ultoa PROC ; IN:EAX=dwNbr, ECX=lpsz
test eax, eax
jnz short L1
lea eax, [ecx+1]
mov byte ptr[ecx], 48
mov byte ptr[eax], 0
ret 0
L1:
mov [esp-4], edi
mov [esp-8], ecx
mov edi, ecx
mov ecx, eax
L2:
mov eax, -858993459
mul ecx
mov eax, edx
shr eax, 3
mov edx, ecx
lea ecx, [eax+eax*8]
add ecx, eax
sub edx, ecx
add dl, 48
mov [edi], dl
mov ecx, eax
inc edi
test eax, eax
jnz short L2
mov [esp-12], edi
mov eax, [esp-8]
mov byte ptr[edi], 0
L3:
dec edi
mov dl, [eax]
mov cl, [edi]
mov [edi], dl
mov [eax], cl
inc eax
cmp eax, edi
jb short L3
mov eax, [esp-12]
mov edi, [esp-4]
ret 0
ultoa ENDP
END start
Conclusion
Je mettrai a jour le code plus tard pour rectifier certains trucs qui ne doivent pas aller.
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|