Results 1 to 4 of 4

Thread: uFlags and

  1. #1
    Join Date
    Mar 2012
    Posts
    56

    Default uFlags and

    if I understand well the uFlags parameter always assume that each uflag bit holds 1 byte. In your documentation you make an example of processing R,G,B channels using 1 | 2 | 4 flags. Is it me or I cannot understand why? Let's take a 24 bits image 3 channels (R,G,B) 1 byte per channel. I would expect the flags to be 0| 1| 2 can you explain why is it not like this. I can't seem to graps the logic behind.
    You write in your documentation also: "If bit N is set, channel N is processed. If bit N is not set, channel N is skipped"
    Thanks.

  2. #2
    Join Date
    Mar 2006
    Posts
    874

    Default Re: uFlags and

    "each uflag bit holds 1 byte"

    Each uFlags bit is one bit. There are 32 bits in the four bytes of uFlags' UINT32.

    If you are setting bits 0, 1, 2, then the value in uFlags is 7, because:

    Code:
    00000000000000000000000000000001 = 1
    00000000000000000000000000000010 = 2
    00000000000000000000000000000100 = 4
    And 1 | 2 | 4 = 7
    "|" is binary OR.


    You write in your documentation also: "If bit N is set, channel N is processed. If bit N is not set, channel N is skipped"
    Correct.
    Ex. If you have a 3 channel image (R,G,B), you can skip channel 0 by setting only bits 1 and 2 (2 | 4 = 6). Or you can process just the Red channel (channel 0) by setting just bit 0: which is a value of1.

  3. #3
    Join Date
    Mar 2012
    Posts
    56

    Default Re: uFlags and

    Thanks a lot I think I got it, but since I am not a binary lover :O (please don't jump on me just to make sure would you be so kind to describe the setting of uflags for the following case:

    Process RGBA (RGB+4th byte=alpha channel) 8 bits per channel
    Process RGBA (RGB+4th byte=alpha channel) 16 bits per channel

    thanks


    [QUOTE=Admin;11256]"each uflag bit holds 1 byte"

    Each uFlags bit is one bit. There are 32 bits in the four bytes of uFlags' UINT32.

    If you are setting bits 0, 1, 2, then the value in uFlags is 7, because:

    Code:
    00000000000000000000000000000001 = 1
    00000000000000000000000000000010 = 2
    00000000000000000000000000000100 = 4
    And 1 | 2 | 4 = 7
    "|" is binary OR.

  4. #4
    Join Date
    Mar 2006
    Posts
    874

    Default Re: uFlags and

    Code:
    00000000000000000000000000000001 = 1 
    00000000000000000000000000000010 = 2 
    00000000000000000000000000000100 = 4
    00000000000000000000000000001000 = 8
    so OR them together (which, since none of the bits overlap, is equivalent to addition), all four channels = 15 (1 | 2 | 4 | 8)

    Code:
    00000000000000000000000000001111 = 15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •