Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Bitmap Image Filters
Subject:   handle alpha channel?
Date:   2002-08-08 21:12:34
From:   psheldon
"p1 = srcData + 3 * (y * w + x);" in IAGrayscaleFilter.m I believe does not as needs n in place of 3, I think.


I must be missing something because I don't see a change needed. Or maybe I learned enough to be of use in this article.


;-)

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Michael Beam photo handle alpha channel?
    2002-08-09 17:19:22  Michael Beam | O'Reilly Author [View]

    That's part of the solution. The other part has to do with the alpha channel occupying the first 8 bits of a pixel, so you have to offset your red, green, and blue indices by 1. So i had something like the following in the inner for-loop:

    *p2 = (char)rint((*(p1 + ao) + *(p1 + 1 + ao) + *(p1 + 2 + ao)) / 3);

    where ao (alpha offset) is determined at the start of the method as:

    int ao = [srcImageRep hasAlpha] ? 1 : 0;

    See if that works for you...

    Mike
    • ah you had given me support by giving me a problem to solve
      2002-08-10 10:16:59  psheldon [View]

      I do need some (easy) problems.

      I don't get the syntax on right hand side of :
      int ao = [srcImageRep hasAlpha] ? 1 : 0;
      supposedly setting a0 to 1.

      Are ? and : c operators and is this rhs c syntax?

      My c pdf file from an old codewarrior has awful hypertexting.
      • friend Dan Van Bose in Fort Worth explained syntax
        2002-08-11 14:40:41  psheldon [View]

        c = boolean ? a : b

        c evaluates to first symbol after ? if boolean true and second expression if false.

        So, this sentence commands skipping by an offset if Alpha is there and mixing 3 colors only.

        I understand now.