Convert NSImage to FireMonkey TBitmap

Hello,



I am building a Mac OS X Application, but facing a small problem, not related to mCL actually, but do any one knows how to convert an NSImage to a FireMonkey Bitmap, I am receiving this NSImage from Objective C API.



Many thanks,

Hi, 


In mCL, specifically the FMX.TMSNativeNSBaseControl unit, there is a function that converts the NSImage to a TBitmap: function BitmapFromImage(AImage: NSImage): TBitmap;

Kind Regards, 
Pieter

Thank you for your reply, I actually asked this question on Stackoverflow:

http://stackoverflow.com/questions/33092942/how-to-convert-nsimage-to-firemonkey-tbitmap, can I have your permission to add the code there (Highlighting your contribution) or if you like you can post it there yourself.



Thanks

Sorry, the mCL license does not permit this.

Hi,



I tried the code, in PAServer terminal, I received the following message:

This application is assuming that a particular image contains an NSBitmapImageRep, which is not a good assumption. We are instantiating a bitmap so that whatever this is keeps working, but please do not do this. Break on void _NSPrivateIconImageRepSubclassAssumedToBeBitmap() to debug. This will be logged only once. This may break in the future.



I assume this is being accounted for in the series of "if Assigned"checks...



Regards,

Nader


No worries, thank you for your feedback, I do appreciate it.



Regards,

Hi, 


This code originates from an older iOS version, and it could be deprecated in a future iOS version, but we haven't found a valid solution to transfer an NSImage to a TBitmap. Whenever the NSBitmapImageRep breaks, the code should be safe as it checks for assignments. As soon as we have found a solution, we will replace the current code.

Kind Regards, 
Pieter


Any update on this...

Sorry, we still haven't found a workaround to ignore this warning, but the code is still valid.

Yes, I understand the code is valid from a "safety" perspective, but it is not working :)

I previously posted this question on stackoverflow, would you kindly check it:
http://stackoverflow.com/questions/33092942/how-to-convert-nsimage-to-firemonkey-tbitmap

Regards

We have invesigated this further and changed the conversion routine, converting the original NSImage to a NSData via the TIFFRepresentation function. The next version will have this included.

Awesome!!!