Lazarus

Miscellaneous => Other => Topic started by: Sandrix on December 17, 2009, 08:28:57 am

Title: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 17, 2009, 08:28:57 am
Hi guys,

I've searched  the forum but I didn't find any comprehensive suggestions about my issue.
I'm on Mac, I have installed lazarus on both of my Macs(iMac intel, Alubook g4 ppc).

I don't know much about 10.5 or 10.6 Api-s so I need you help.

Does anyone know how to create a form like this:

http://www.arunalabs.com/blogs/wp-content/uploads/2007/08/aruna_send_yahoo_widget.png

Not just a rounded form, but a PNG image with all it's alpha-blending features.

I know how to do it on Delphi win, there's a great lib from progdigy called Gdiplus, But I can't find any alternatives for mac.

So please help me out guys

Thanks and sorry about my poor English.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 18, 2009, 07:44:08 am
anyone?  :-\
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on December 18, 2009, 10:19:26 am
I'm afraid there's no ready to use solution.

It's easy to make the whole window transparent (or adjust the transparency), but using a transparent image as window's form might be harder.  Especially for LCL, due to LCLCarbon internal implementation.

If you could find a C-sample on how to do it, using pure Carbon API, I can help you adopting it to Lazarus.

p.s. But i'll be away until 29th of december.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 18, 2009, 11:35:47 am
Thanks for your reply,

I'll  try to find something...  and will post it ASAP

Thanks a gain
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 18, 2009, 12:00:01 pm
******UPDATE

I found this.. 

http://uploadbox.com/files/be585d8b20/

and alos some examples for delphi:

http://melander.dk/articles/alphasplash2/2/

http://stackoverflow.com/questions/1228820/fade-in-an-alpha-blended-png-form-in-delphi
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on December 18, 2009, 12:38:46 pm
sorry. this samples are about how-to do make png-image shaped forms in Windows.
And i guess you need the same for OSX.

So the samples should also be applied for Mac OS X, and not Windows. Since Lazarus and Pascal is not much popular on OSX system, it's normal if you find C or C++ code.

You can search for samples at: developer.apple.com site. There might be useful links at lists.apple.com (apple developers mailing list)
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 18, 2009, 12:50:23 pm
have you look at the first link? there are two projects available for download. Written on cocoa and pure Carbon api
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on December 18, 2009, 03:20:39 pm
have you look at the first link? there are two projects available for download. Written on cocoa and pure Carbon api
yes. Both projects from the link are Cocoa based. Not Carbon.
To bad, that some code is actually "hidden" because both projects are using Interface Builder.

I'm afraid there won't be solution today.

upd: have found the carbon sample.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on December 18, 2009, 06:13:44 pm
here you go
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 19, 2009, 01:33:16 am
OMFG thanks alot  :o

The only thing as that img has some strange black gasps...  and also it mirrors itself if you try to  replace the circle.png with SomethingElse.png.

(http://img13.imageshack.us/img13/3545/picture1st.th.png) (http://img13.imageshack.us/i/picture1st.png/)

Any ideas?

I think TFPImageBitmap is the reason for this.. PNG is recognized as 8 bit image... it should be 24.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Ñuño_Martínez on December 21, 2009, 05:01:12 pm
May be you have a problem with the alpha channel. Load it with a graphic editor (i.e. The GIMP, Photoshop or similar) and see if it's all right. Also be sure that the transparent part is "plain".
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 21, 2009, 05:13:13 pm
no there's nothing wrong with an alpha channel. Plus it'sa same img that was in you zip file. Try it by yourself. make a simple shape in PS and export it as a png. Replace the original circle.png with your file. Pls let me know how it goes  :) thanks again
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on December 29, 2009, 11:14:19 am
It's caused by some LCL->carbon features...
Anyway, i've fixed OSXUtils.pas file, and now the transparent image should be drawn correctly.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on December 30, 2009, 08:09:24 pm
 %)
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on January 02, 2010, 01:52:19 pm
 :D I'm sorry, I've forgotten to remove "debug drawing"

please test the fixed osxutils
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: marco_gamelix on January 02, 2010, 02:34:28 pm
Wow, that's very cool guys!

I would like to do the same thing on Mac, could you share the sample Pascal code?  :-\
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on January 02, 2010, 02:44:12 pm
do you mean to use OSXUtils.pas? sure things!

maybe it will be added as Lazarus-CCR component.

Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: marco_gamelix on January 02, 2010, 02:47:35 pm
That would be great! Yes, please :)
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on January 02, 2010, 07:26:20 pm
btw, the pascal sample is available at testTransp.zip (see the 1st page)
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on January 03, 2010, 01:57:12 am
works fine now but img is still mirrored  :'(
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: skalogryz on January 03, 2010, 11:49:40 am
should be fixed now.
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Sandrix on January 03, 2010, 03:30:12 pm
hurray!!! works like a charm!
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Shebuka on September 15, 2017, 06:42:12 pm
Hi all!
I've just found that this function is not working anymore on recent macOS's.

Verified on Mac OS X 10.11.6 and macOS 10.12+, the resulting form has a black color instead of transparency.

@skalogryz, can you see if this can be fixed?

Lazarus 1.6.4;
FPC 3.0.2.

EDIT: Seems to work fine again on Carbon
Title: Re: [Laz Mac OSX] How to create a custom form from PNG image?
Post by: Shebuka on June 14, 2019, 09:56:31 am
Are there any chances to make this work on Cocoa?

EDIT: There is this article from Matt (http://www.cocoawithlove.com/2008/12/drawing-custom-window-on-mac-os-x.html) on how to do it in Objective-C, but I don't know how to translate it into LCLCocoa code.
TinyPortal © 2005-2018