Page 1 of 1

PNG with Alphachannel

Posted: Fri Dec 02, 2011 11:29 pm
by infratec
Hi,

I have no Mac... but I want to make my programming running on a Mac!

I have only a few points which aren't working.
One of them:

I have an ImageGadget() on the window. The window is red.
The image is a 4 color PNG with alphachannel.
I use CatchImage() to load it.

Result:
The background of the image is not transparent. It is white.

On windows it is working.

Is there a 'special' trick for Mac?

I think I also tried a 24bit colour with alphachannel. Same effect.

Bernd

Re: PNG with Alphachannel

Posted: Fri Dec 02, 2011 11:33 pm
by J. Baker
I thought png only did 32bit w/alpha and 8bit w/alpha?

Re: PNG with Alphachannel

Posted: Fri Dec 02, 2011 11:43 pm
by jesperbrannmark
I know this is very sensitive on the mac. even if i screwed up the image slightly on windows - it didnt display or showed up as wrong. on mac my program crashed.
So bottom line - be careful and put in extra checks (which you should do doing good practice). use if isimage(XXX) for... well... everything.

Re: PNG with Alphachannel

Posted: Fri Dec 02, 2011 11:55 pm
by infratec
Hi,

here is a code snippet for testing:

Code: Select all

UsePNGImageDecoder()

OpenWindow(0, 0, 0, 300, 250, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0, $0000CC)

CatchImage(0, ?Logo)
ImageGadget(0, 50, 50, 195, 150, ImageID(0))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

DataSection
  Logo: IncludeBinary "GuzziForumLogo.png"
EndDataSection
And here is the picture (save it as GuzziForumLogo.png):

Image

And yes, it is 24bit with alphachannel. And it works in windows.
But not in Linux and not on Mac. :cry:

Bernd

Re: PNG with Alphachannel

Posted: Fri Dec 02, 2011 11:58 pm
by jesperbrannmark
Works fine with me. Pb 4.6, lion, macbook air.
but that red color is ugly

Re: PNG with Alphachannel

Posted: Sat Dec 03, 2011 12:01 am
by jesperbrannmark
Sorry. thoght it was a bug.
here is working transparent :

Code: Select all

UsePNGImageDecoder()

OpenWindow(0, 0, 0, 300, 250, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0, $0000CC)

CatchImage(0, ?Logo)
CreateImage(1,ImageWidth(0),ImageHeight(0))
StartDrawing(ImageOutput(1))
Box(0,0,ImageWidth(0),ImageHeight(0),$0000cc)
DrawAlphaImage(ImageID(0),0,0,254)
StopDrawing()
FreeImage(0)
ImageGadget(0, 50, 50, 195, 150, ImageID(1))


Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

DataSection
  Logo: IncludeBinary "Gussi.png"
EndDataSection

Re: PNG with Alphachannel

Posted: Sat Dec 03, 2011 12:13 am
by infratec
Hi,

but when I set the colour of the box, than I don't need a transparent picture :!:

In windows it looks like this:

Image

That was the reason for transparency.
It is in the lower right corner and overlaps the statusbar.

Bernd