PNG with Alphachannel

Mac OSX specific forum
infratec
Always Here
Always Here
Posts: 7792
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

PNG with Alphachannel

Post 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
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: PNG with Alphachannel

Post by J. Baker »

I thought png only did 32bit w/alpha and 8bit w/alpha?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: PNG with Alphachannel

Post 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.
infratec
Always Here
Always Here
Posts: 7792
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PNG with Alphachannel

Post 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
Last edited by infratec on Fri Dec 02, 2011 11:58 pm, edited 1 time in total.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: PNG with Alphachannel

Post by jesperbrannmark »

Works fine with me. Pb 4.6, lion, macbook air.
but that red color is ugly
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: PNG with Alphachannel

Post 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
infratec
Always Here
Always Here
Posts: 7792
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PNG with Alphachannel

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