drawing an image with an alpha channel

I have a sample app where I want to draw images with alpha channels so overlapping images will show the image underneath. No matter what I do, I can’t get that to work. If I query the hasalphachannel property, it responds that the image has an alpha channel.

I am using a canvas with a picture buffer to draw the images inside a larger canvas., as per Eugine Dakin’s ebook on how to use a canvas.

Mac OSX 10.12.6
Xojo 2018R2

The XOJO project can be downloaded from http://cultconv.com/YB.xojo_binary_project.zip

All assistance appreciated. This is doing my head in.

bobj

Create a picture using

dim pic as new picture (200,200)

Thats transparent by default.
Draw a circle on it.

Now .drawpicture pic, 20,20 on another image… only the circle will affect the second image.

Jeff,

Thanks for your reply. My situation is a little different, as per the sample app I uploaded. I have a png image with an alpha channel. I draw that picture into two canvas objects which are on a background canvas control. If I drag one of those canvas objects over the other canvas object, the one underneath does not show through the transparent part of the top image. The transparent parts of the top image are drawn as solid white not as transparent.

That is my problem, I need the bottom image to be visible through the transparent parts of the top image.

BobJ

Hi Bob, I downloaded your project and deleted all trailing “, 32” from all “New Picture” commands in your project. This way all transparent parts are no longer white and overlapping objects show through these transparent parts.
Did you ever consider using Pixmapshape?

Joop

Thank you for your reply. I thought I had removed all the ,32 texts but obviously had not.

Thank you for pointing this out. I will go back and in and make all the changes and hopefully wil get it working as well.

Had not considered Pixmapshape. Not sure what it does. I will look into it though.

Thank you again.
BobJ

Joop,

did as you suggested and you’re right, it now works. Interestingly though, I found I had to leave one new picture command with the ,32 attribute. That is the one in the one in the INIT method of the CustomCanvas control. This controls the drawing of a canvas object whilst being dragged. Take out the ,32 attribute and each draw of the object as it is being dragged remains on the screen creating a terrible mess of rectangles. Leave it in and al you see is a single rectangle being dragged across the window and finally draw in place.

thanks for your help, you’ve saved my bacon.

bobj