|
-
Jul 8th, 2004, 10:52 AM
#1
Thread Starter
G&G Moderator
Pixel Values [Resolved]
Howdy all,
Ok, I might aswell try asking here. I've posted in the C/C++ forum because I don't believe many people come to this Assembly forum, but here goes.
I'm wanting to get the Red Green and Blue values of a pixel. I'm wanting something like these in Assembly (MASM, but any other is fine aswell).
Code:
//C++ Version
#define GetRValue(rgb) ((BYTE)(rgb))
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
#define GetBValue(rgb) ((BYTE)((rgb)>>16))
VB Code:
'VB Version
Function GetRedVal(val As Long) As Long
GetRedVal = val& Mod 256
End Function
Function GetGreenVal(val As Long) As Long
GetGreenVal = ((val And &HFF00) / 256&) Mod 256&
End Function
Function GetBlueVal(val As Long) As Long
GetBlueVal = (val And &HFF0000) / 65536
End Function
Any help is greatly appreciated.
Thanks in advance,
Phreak
Last edited by «°°phReAk°°»; Jul 8th, 2004 at 06:29 PM.
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Jul 8th, 2004, 06:29 PM
#2
Thread Starter
G&G Moderator
I figured it out after nearly a full 24 hours:
http://www.vbforums.com/showthread.p...95#post1730895
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Jul 9th, 2004, 08:17 AM
#3
Fanatic Member
code:--------------------------------------------------------------------------------
invoke GetPixel,hDC,0,0
; RED
and eax,00FF0000h
shr eax,16
; BLUE
and eax,00FF0000h
; GREEN
and eax,0000FF00h
--------------------------------------------------------------------------------
Wouldn't it be simpler if red was:
invoke GetPixel,hDC,0,0
; RED
and eax,000000FFh
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 9th, 2004, 05:02 PM
#4
Thread Starter
G&G Moderator
LOL. I suppose it would. The first time I figured out how I would get each value, was with blue. So I was just lazy and shifted it 
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|