Page 1 of 1

Mask / alpha questions

Posted: Thu Feb 07, 2013 11:01 pm
by Mazze
Hi,

I want to load and save brushes with transparency in HollyPaint.

What I've gathered from the documentation:
Mask and alpha channel are mutually exclusive.
#IMGFMT_PNG saves alpha channel if available.

RotateBrush and SetBrushTransparency are supposed to create a mask. What happens if the brush already has an alpha channel?

Re: Mask / alpha questions

Posted: Fri Feb 08, 2013 12:50 am
by Allanon
From my knowledge RotateBrush() should use the existing alpha channel rotatin git accordingly (I've used it on PNG images), don't know what happen with SetBrushTransparency()

Re: Mask / alpha questions

Posted: Sat Feb 09, 2013 4:08 pm
by Mazze
OK, I'm assuming that the brush functions can handle both mask and alpha channel.

I'm loading the alpha channel if available:

Code: Select all

    Local ispic, table = IsPicture(filename)
    If ispic
        Local newbrush = LoadBrush(Nil, filename, {LoadAlpha=table.Alpha})
I'm changing from mask to alpha channel before saving:

Code: Select all

    If GetAttribute(#BRUSH, Brush.brush, #ATTRHASMASK)
        ChangeBrushTransparency(Brush.brush, #ALPHACHANNEL)
    EndIf
    SaveBrush(Brush.brush, filename, Canvas.backcolor, #IMGFMT_PNG)
Seems to work so far.

Re: Mask / alpha questions

Posted: Sun Feb 10, 2013 10:53 pm
by airsoftsoftwair
SetBrushTransparency() will always create a mask for the brush. If the brush already has an alpha channel, it will be deleted.

All the other image processing functions like RotateBrush(), ScaleBrush(), etc. work with both, mask and alpha channel. If there is a mask or an alpha channel, it will be processed as well.