[Laz Mac OSX] How to create a custom form from PNG image? lazarus / 8-Other ---------------------------------------------------------------------- Sandrix · 2009-12-17 07:28 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. ---------------------------------------------------------------------- Sandrix · 2009-12-18 06:44 anyone? ---------------------------------------------------------------------- skalogryz · 2009-12-18 09:19 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. ---------------------------------------------------------------------- Sandrix · 2009-12-18 10:35 Thanks for your reply, I'll  try to find something...  and will post it ASAP Thanks a gain ---------------------------------------------------------------------- Sandrix · 2009-12-18 11:00 ******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 ---------------------------------------------------------------------- skalogryz · 2009-12-18 11:38 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) ---------------------------------------------------------------------- Sandrix · 2009-12-18 11:50 have you look at the first link? there are two projects available for download. Written on cocoa and pure Carbon api ---------------------------------------------------------------------- skalogryz · 2009-12-18 14:20 Quote from: Sandrix on December 18, 2009, 12:50:23 pmhave 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. ---------------------------------------------------------------------- skalogryz · 2009-12-18 17:13 here you go ---------------------------------------------------------------------- Sandrix · 2009-12-19 00:33 OMFG thanks alot 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) Any ideas? I think TFPImageBitmap is the reason for this.. PNG is recognized as 8 bit image... it should be 24. ---------------------------------------------------------------------- Ñuño_Martínez · 2009-12-21 16:01 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". ---------------------------------------------------------------------- Sandrix · 2009-12-21 16:13 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 ---------------------------------------------------------------------- skalogryz · 2009-12-29 10:14 It's caused by some LCL->carbon features... Anyway, i've fixed OSXUtils.pas file, and now the transparent image should be drawn correctly. ---------------------------------------------------------------------- Sandrix · 2009-12-30 19:09 ---------------------------------------------------------------------- skalogryz · 2010-01-02 12:52 I'm sorry, I've forgotten to remove "debug drawing" please test the fixed osxutils ---------------------------------------------------------------------- marco_gamelix · 2010-01-02 13:34 Wow, that's very cool guys! I would like to do the same thing on Mac, could you share the sample Pascal code? ---------------------------------------------------------------------- skalogryz · 2010-01-02 13:44 do you mean to use OSXUtils.pas? sure things! maybe it will be added as Lazarus-CCR component. ---------------------------------------------------------------------- marco_gamelix · 2010-01-02 13:47 That would be great! Yes, please ---------------------------------------------------------------------- skalogryz · 2010-01-02 18:26 btw, the pascal sample is available at testTransp.zip (see the 1st page) ---------------------------------------------------------------------- Sandrix · 2010-01-03 00:57 works fine now but img is still mirrored ---------------------------------------------------------------------- skalogryz · 2010-01-03 10:49 should be fixed now. ---------------------------------------------------------------------- Sandrix · 2010-01-03 14:30 hurray!!! works like a charm! ---------------------------------------------------------------------- Shebuka · 2017-09-15 16:42 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 ---------------------------------------------------------------------- Shebuka · 2019-06-14 07:56 Are there any chances to make this work on Cocoa? EDIT: There is this article from Matt on how to do it in Objective-C, but I don't know how to translate it into LCLCocoa code.