Results 1 to 2 of 2

Thread: Pixel Values [Resolved]

  1. #1

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Pixel Values [Resolved]

    Howdy all,

    I know this is the C/C++ forum, but the Assembly forum is pretty much dead. I'm wanting to know what the following code would be in ASM (MASM really):
    Code:
    #define GetRValue(rgb)      ((BYTE)(rgb))
    #define GetGValue(rgb)      ((BYTE)(((WORD)(rgb)) >> 8))
    #define GetBValue(rgb)      ((BYTE)((rgb)>>16))
    I'm wanting to retrieve the Red Green and Blue values of a picture on a DC.

    Any help would be great.

    Phreak
    Last edited by «°°phReAk°°»; Jul 8th, 2004 at 06:28 PM.

    Visual Studio 6, Visual Studio.NET 2005, MASM

  2. #2

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Well, as it turns out, ALOT of experimenting helps. I figured it out myself, and in case anyone wondered, heres what I have.
    Code:
    invoke GetPixel,hDC,0,0
    ; RED
    and eax,00FF0000h
    shr eax,16
    
    ; BLUE
    and eax,00FF0000h
    
    ; GREEN
    and eax,0000FF00h
    If you look at it, its nearly the opposite to the C code (but it gets results!). I'm shifting the red value, instead of the blue value, and the green value isn't shifted at all.

    Anyway, it's working now.

    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
  •  



Click Here to Expand Forum to Full Width