Mask / alpha questions

Discuss any general programming issues here
Post Reply
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Mask / alpha questions

Post 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?
User avatar
Allanon
Posts: 742
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Mask / alpha questions

Post 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()
----------------------------
[Allanon] Fabio Falcucci | GitHub (leaving) | Gitea (my new house) | My Patreon page | All my links
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Re: Mask / alpha questions

Post 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.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Mask / alpha questions

Post 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.
Post Reply