Alpha channel and datatypes
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Dietmar
    Posts: 114 from 2003/2/26
    From: Aachen, Germany
    Hi,

    I'm trying to read the ARGB data of an image by invoking the PDTM_READPIXELARRAY method on a datatype object (with bpa.pbpa_PixelFormat = PBPAFMT_RGBA).

    The intention is to cache the raw data. The image will later be rendered via WritePixelArray( ..., RECTFMT_RGBA).

    It appears that neither reading nor rendering works correctly: the alpha channel is ignored. I'm aware that this approach doesn't work under OS3 but shouldn't this work under MorphOS?!
  • »14.03.07 - 18:08
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    PDTM_READPIXELARRAY works correctly (at least with PBPAFMT_ARGB) but WritePixelArray() ignores alpha channel completely. You need undocumented WritePixelArrayAlpha() instead.
    1 + 1 = 3 with very large values of 1
  • »14.03.07 - 18:52
    Profile
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Dietmar
    Posts: 114 from 2003/2/26
    From: Aachen, Germany
    Quote:

    You need undocumented WritePixelArrayAlpha() instead


    In that case I'll use a custom function. Does anybody have a working solution that is faster than the read-mix-write approach (read to an off-screen buffer with ReadPixelArray(), use CPU to mix with image, write back with WritePixelArray())?
  • »14.03.07 - 19:41
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Just use WritePixelArrayAlpha() and you benefit from possible future enhancements:

    #ifndef WritePixelArrayAlpha
    #define WritePixelArrayAlpha(__p0, __p1, __p2, __p3, __p4, __p5, __p6, __p7, __p8, __p9) \
    LP10(216, ULONG , WritePixelArrayAlpha, \
    APTR , __p0, a0, \
    UWORD , __p1, d0, \
    UWORD , __p2, d1, \
    UWORD , __p3, d2, \
    struct RastPort *, __p4, a1, \
    UWORD , __p5, d3, \
    UWORD , __p6, d4, \
    UWORD , __p7, d5, \
    UWORD , __p8, d6, \
    ULONG , __p9, d7, \
    , CYBERGRAPHICS_BASE_NAME, 0, 0, 0, 0, 0, 0)
    #endif

    It is same as WritePixelArray() except that last argument is not pixel format but global alpha (0x0 - 0xffffffff) and it supports ARGB pixel format only.

    It is really private but it has spread to OS4 and AROS and available in AfA OS also.


    [ Edited by itix on 2007/3/15 0:18 ]
    1 + 1 = 3 with very large values of 1
  • »14.03.07 - 22:15
    Profile
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Dietmar
    Posts: 114 from 2003/2/26
    From: Aachen, Germany
    Quote:

    It is really private but it has spread to OS4 and AROS and available in AfA OS also.

    Thanks for the help. I have noticed that under MorphOS, my test code only works correctly with ARGB (as you said) but under AfaOS, it only works with RGBA?! ARGB gives a blank rectangle. Any idea?
  • »15.03.07 - 11:40
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    I suppose AfA OS is broken.
    1 + 1 = 3 with very large values of 1
  • »15.03.07 - 13:37
    Profile
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Dietmar
    Posts: 114 from 2003/2/26
    From: Aachen, Germany
    On second look, the culprit seems to be the png datatype. WritePixelArrayAlpha() works fine but all alpha values are zero. I was under the impression that warpPNG and/or akPNG would fully support alpha (they both have an option in their GUI).
  • »15.03.07 - 17:31
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Dietmar
    Posts: 114 from 2003/2/26
    From: Aachen, Germany
    Oops, it was the picture datatype. Everything works fine now.
  • »15.03.07 - 17:47
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Honestly datatypes suck.
    1 + 1 = 3 with very large values of 1
  • »15.03.07 - 23:15
    Profile
  • akl
  • Just looking around
    akl
    Posts: 10 from 2004/7/31
    Alpha works with PDTM_WRITEPIXELARRAY as well (at least under MorphOS/CGfx and WinUAE/Picasso96) but some combinations of pic-dt and cgfx may cause problems.

    akPNG supports alpha - it has been tested under the configs mentioned before.
  • »17.03.07 - 17:52
    Profile Visit Website