Alpha Channel Tranparency Lost

I’m loading small Oval png transparent Images with an Alpha Channel mask to the graphics layer of a canvas layered on top of a larger Image that fills the whole canvas. I recently learned a new better OOP way to do it with Eugene Dakin Canvas eBook from his Chapter 7 Object Ex. 7-2. It uses a memory Buffer to load the Canvas Objects. I got it to work great but the png Image looses it’s Alpha Channel and the Ovl png show it square white outline that was originally transparent. I not going to write any code good because there is too many object methods & properties. My last post nobody replied because it was so over whelming with all the code.

My question why is the Alpha Channel Transparency mask being lost form the picture? From what I understand the Alpha Channel has to be on top and it must be Black for the areas that you want to be Transparent and the mask cutout must be intact for the part of the Image your want to show (Oval).

How is it being lost and how do I keep it intact?

I looked through your history and could not find any such post.

Alpha Channel and Transparency Masks are mutually exclusive. You have one or the other, not both.
http://documentation.xojo.com/index.php/Picture.HasAlphaChannel

I don’t have access to Eugene’s book, but I’d say double check your code (especially if you copy/pasted any example code.)

Thanks Tim - I deleted the last post to rewrite it. Thanks for the link in the documentation - I’ve never seen it. The Images have an Alpha Channel. I cut the mask out with Gimp 2. I thought mask and Alpha channel were one in the same I did know they were exclusive. In Gimp it shows an Alpha Channel. I’ll try to incorporate what’s in the docs to my project code

Thank You for the reply

I’m Trying to incorporate the HasAlphaChannel Function into my project in the code below. Is there any better ways on how to.

CustomCanvas.ModernizePicture(input As Picture) As Picture

If input.HasAlphaChannel Then Return input

Dim result As New Picture( input.Width, input.Height )
result.Graphics.DrawPicture( input, 0, 0 )
Return result
End Function

CustomCanvas.DrawClassObject(X as Integer, Y as Integer, Width as Integer, Height as Integer)
Dim i, Maxi as Integer
Dim TmpClass as FrtBrdCvsClass
Dim PicLeft, PicTop as Integer
Dim input As Picture

'Redraw the CanvasClasses which are in the range of the canvas
Maxi = UBound(MyCanvasClasses)
For i = 0 to Maxi
TmpClass = MyCanvasClasses(i)
If TmpClass.NtVisCls = True Then
PicLeft = TmpClass.XCls - TmpClass.NtWidthCls/2
PicTop = TmpClass.YCls - TmpClass.NtHeightCls/2
If (PicLeft+TmpClass.NtWidthCls > x) and (PicLeft < X + Width) and (PicTop + TmpClass.NtHeightCls > Y) and (PicTop < Y + Height) Then

'Remove This
’ PBuffer.Graphics.DrawPicture(TmpClass.PBufferCls, PicLeft, PicTop)

’ This is my best shot at it, Any better sugestions ??
input = me.Graphics.DrawPicture(TmpClass.PBufferCls, PicLeft, PicTop)
me.ModernPicture(input, PicLeft, PicTop))
PBuffer.Graphics.DrawPicture(input, PicLeft, PicTop)

  End If
End If

Next i

'Draw to the canvas
Self.Graphics.DrawPicture(PBuffer, X, Y, Width, Height, X, Y, Width, Height)

I’m trying to delete the code above because I totally messed it it up but I can’t.

I meant
input.Graphics.DrawPicture(TmpClass.PBufferCls, PicLeft, PicTop)
not
input = me.Graphics.DrawPicture(TmpClass.PBufferCls, PicLeft, PicTop)

Wouldn’t it be easier to use Graphics.FillOval on top of the image? It offers the advantages that you wouldn’t need an image of the oval, it would automatically be transparent, and you would be one step closer to retina ready.

I’m might be possibly doing away with image all together and just creating the image with code with graphics.DrawOval .DrawSquare DrawString. and your can customize the color with Graphics.FillRect and FillOval very easy as you suggested above. I did an experiment outside my project and it actually looked better and would save a lot of time and resources. If I can create a border within the oval and square image then I will go with that.

Thanks Tim