Create transparent PNG

I have a transparent PNG. If I save this to a BLOB field, retrieve it and display again, the transparency is gone. It should be possible to create a mask and recreate the transparency. How to do this?

Did you save it and load it as it png?

As type Picture…

https://documentation.xojo.com/api/graphics/picture.html#picture-todata

What are the prameters that you use?
Png should keep transparency…

 Var picData as String = myPic.ToData(Picture.Formats.png)

Save picData to db and read back should be exactly the same…

Use that code. Still transparency gone, turned into black, that is.

Black ok probably something is different here ill have a look how we do this.

Edit:
Do you use a canvas to draw the picture to?

Edit:
Do you use a canvas to draw the picture to?

It’s an PNG that the user selects; first time displays in a canvas. Then it gets stored in a table. After retrieval it is displayed in a Toolbar as icon.

Extract the image file directly from the table and save it to disk, check if the image has transparency or if you save it withouth.

As a good practice, store pictures, keep the orifginal data in a variable, from the file that the user choosed, then save this in the table instead of compressing again the picture in xojo

Picture.ToData returns a MemoryBlock. A string has an encoding. May it happen that the encoding destroyes some bytes into the picture data?

Maybe… haven’t tested that.