Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Resolution under Delphi XE5

I started to develop a game under Delphi XE5 for iOS. I have problem with the Resolution feature of the Firemonkey.

When I open the screen and I check resolution on the iPhone I get 320x480. But the native resolution of the iPhone 4 and 5 is doubled. I found at official Delphi pages that FireMonkey is recalculating the screen by "Resolution" which is for Retina display 2.

I think this is cool feature for regular apps, but when you start to do game and you want to manipulate with images by code it brings weird situations.

My question is - is there way to find the actual Resolution value or at least what is the actual device type (iPhone,iPad?)

thanks

like image 502
Pavel Jiri Strnad Avatar asked Nov 21 '13 14:11

Pavel Jiri Strnad


1 Answers

ok, we found the answers.

There is unit FMX.Platform that procides quite vital data.

var
 ScreenSvc: IFMXScreenService;
begin
 if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenSvc)) then
begin
   <your code>
 end;
end;

and the result values are:

 ScreenSvc.GetScreenSize.X
 ScreenSvc.GetScreenSize.Y  
 ScreenSvc.GetScreenScale
like image 51
Pavel Jiri Strnad Avatar answered Oct 27 '22 11:10

Pavel Jiri Strnad