How to convert the Integer representation of VCL.TColor to a FMX.TColor

Hello,

I am currently porting (parts) of a VCL application to an FMX application to run it on iOS devices.
In the VCL application documents are saved that contain TColor values casted as Integers.

I'd like to read those (VCL) documents and show them on iOS.
How can I convert the Integer number (that represents a VCL TColor value) to a FMX TColor?

I think I need the function "ColorToRGB" from the VCL.Graphics unit and then I could
split the resulting RGB value into R,G,B values and then set the R,G,B values of  TColorRec.

But unfortunately the function ColorToRGB  makes use of a Windows function (GetSysColor).

Is there any cross platform solution available?

best regards,

Thomas
0
Thomas
3/6/2012 2:13:42 PM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

3 Replies
7680 Views

Similar Articles

[PageSpeed] 23

> {quote:title=Thomas Degen wrote:}{quote}
> 
> I am currently porting (parts) of a VCL application to an FMX application to run it on iOS devices.
> In the VCL application documents are saved that contain TColor values casted as Integers.

I think you mean FMX.TAlphaColor, which is simply an integer with the two high order bytes containing the alpha channel, but with the RGB order reversed - TAlphaColor is $AARRGGBB, TColor is $BBGGRR. So you can do it with bit shifting:
var FC: TAlphaColor;
  VC: TColor;
TAlphaColorRec(FC).R := VC and $FF;
TAlphaColorRec(FC).G := (VC shr 16) and $FF;
TAlphaColorRec(FC).B := (VC shr 32) and $FF;

(You may need to typecast VC to an integer -= I've not done much work with TColor).
0
Mike
3/6/2012 6:20:57 PM
Hello Mike,

the coversion from RGB to FMX.TAlphaColor is not the problem.
The problem is how to get the RGB value from a VCL.TColor value under iOS.
This is easy if it is a "normal" color then it is just the value but if it is a system color like "clScrollBar"
then a MS Windows function (GetSysColor) is required to get the correct RGB color value for this place holder.

I solved this for now by creating a list of RGB values for all system colors in a Windows/VCL application and
then under iOS I am using this list to translate the system colors to FMX.TAlphaColors. 

best regards,

Thomas

> {quote:title=Mike Sutton wrote:}{quote}
> > {quote:title=Thomas Degen wrote:}{quote}
> > 
> > I am currently porting (parts) of a VCL application to an FMX application to run it on iOS devices.
> > In the VCL application documents are saved that contain TColor values casted as Integers.
> 
> I think you mean FMX.TAlphaColor, which is simply an integer with the two high order bytes containing the alpha channel, but with the RGB order reversed - TAlphaColor is $AARRGGBB, TColor is $BBGGRR. So you can do it with bit shifting:
> var FC: TAlphaColor;
>   VC: TColor;
> TAlphaColorRec(FC).R := VC and $FF;
> TAlphaColorRec(FC).G := (VC shr 16) and $FF;
> TAlphaColorRec(FC).B := (VC shr 32) and $FF;
> 
> (You may need to typecast VC to an integer -= I've not done much work with TColor).
0
Thomas
3/7/2012 8:42:33 AM
Use MakeColor(R, G, B);

Kind Regards,
Scheldeman Pieter

"Thomas Degen" wrote in message news:451193@forums.embarcadero.com...

Hello Mike,

the coversion from RGB to FMX.TAlphaColor is not the problem.
The problem is how to get the RGB value from a VCL.TColor value under iOS.
This is easy if it is a "normal" color then it is just the value but if it 
is a system color like "clScrollBar"
then a MS Windows function (GetSysColor) is required to get the correct RGB 
color value for this place holder.

I solved this for now by creating a list of RGB values for all system colors 
in a Windows/VCL application and
then under iOS I am using this list to translate the system colors to 
FMX.TAlphaColors.

best regards,

Thomas

> {quote:title=Mike Sutton wrote:}{quote}
> > {quote:title=Thomas Degen wrote:}{quote}
> >
> > I am currently porting (parts) of a VCL application to an FMX 
> > application to run it on iOS devices.
> > In the VCL application documents are saved that contain TColor values 
> > casted as Integers.
>
> I think you mean FMX.TAlphaColor, which is simply an integer with the two 
> high order bytes containing the alpha channel, but with the RGB order 
> reversed - TAlphaColor is $AARRGGBB, TColor is $BBGGRR. So you can do it 
> with bit shifting:
> var FC: TAlphaColor;
>   VC: TColor;
> TAlphaColorRec(FC).R := VC and $FF;
> TAlphaColorRec(FC).G := (VC shr 16) and $FF;
> TAlphaColorRec(FC).B := (VC shr 32) and $FF;
>
> (You may need to typecast VC to an integer -= I've not done much work with 
> TColor).
0
Pieter
3/7/2012 9:15:07 AM
Reply:

Similar Artilces:

Vcl to Firemonkey converter
I have found a new program (MIDA) for convert automatically DFM and Pas in FMX and pas. it's GREAT !!! don't convert all, of course, but it is very useful. I converted a project VCL , 20 forms, and I have spent using a morning instead of a week:) i was any TMS Pack component in my project and it work in FM The next version will support more pascal update ( application.MessageBox / application.exename ... ). in the last version of MIDA V. 0.81 is add TPageControl,TTabSheet support and other component two picture from site : http://midafiremonkey.files.wordp...

Ann: FastReport FMX for Delphi XE3 (FireMonkey 2) and XE2 (FireMonkey) released
Dear friends, Visual report designer is available now on both MS Windows and MAC OS X! Full sources. We can write here full list of possibilities, but it will so long. Let see FastReport VCL and FastReport FMX comparison table: http://www.fast-report.com/en/products/comparison-fast-report-firemonkey-vcl.html And all of this - just now in your hands for business-applications for Mac. Report generator FastReport FMX is the first multiplatform solution for including Business Intelligence into software based on Embarcadero FireMonkey IDE (Delphi for MS Windows and Apple Mac OS X)...

how to convert draw from vcl to fmx?
mazemsgform.image1.canvas.draw(0,0,self.picture.bitmap); how would i convert that so it can be used in FMX? > {quote:title=glen morse wrote:}{quote} > mazemsgform.image1.canvas.draw(0,0,self.picture.bitmap); > > how would i convert that so it can be used in FMX? Canvas.Drawbitmap... TCanvas.DrawBitmap(const ABitmap: TBitmap; const SrcRect, DstRect: TRectF; const AOpacity: Single; const HighSpeed: Boolean); Cheers, Peter ...

Free VCL to FireMonkey converter?
Hi I just read this blog post: http://delphi-insider.blogspot.com.br/2012/07/free-mida-vcl-to-firemonkey-converter.html It says that Embarcadero has licensed a special version of Mida, a converter for VCL to FireMonkey applications. As far as I can remember when FireMonkey was released there was a guy that developed this convertion tool and posted some info in the forum and got trolled by many users over here because people were not trusting that that software was real. Is this Mida converter that Embarcadero licensed actually this tool that was developed by him? As far as I can tell ...

converting code from vcl to fmx [Edit]
Hi all With delphi vcl the methods I'm used to using to move a control at runtime no longer apply when I create a firemonkey application. The code is from a windows system only point of view, how can I get the below to work for me? --- if Sender is TWinControl then TWinControl(Sender).Perform(WM_SYSCOMMAND,$F012,0) --- When the above is in the button's OnMouseMove event I can drag a button around at runtime. In firemonkey this no longer applies, how/what is the method I use to do this in firemonkey? With thanks Cheers ...

MIDA a new Vcl to Firemonkey converter
Hi I have found a new program (MIDA) for convert automatically DFM and Pas in FMX and pas. it's GREAT !!! don't convert all, of course, but it is very useful. I converted a project VCL , 20 forms, and I have spent using a morning instead of a week:) i was any TMS Pack component in my project and it work fine in FM ( converted in FM component ) from Mida blog : *Update MIDA V 0.82 – Chart and grid support* ...... in detail i have add support for : TChart , TStringGrid, THeader, TDBGrid, TDBAdvGrid , TcxGrid, Today don’t exist a real dbgrid component fo...

New converter VCL to FireMonkey !!!! [Edit]
I have found a new program (MIDA) for convert automatically DFM and Pas in FMX and pas. it's GREAT !!! don't convert all, of course, but it is very useful. I converted a project VCL , 20 forms, and I have spent using a morning instead of a week:) i was any TMS Pack component in my project and it work in FM :) The next version will support more pascal update ( application.MessageBox / application.exename ... ). two picture from site : Win 32 VCL : http://img836.imageshack.us/img836/9877/vcl.png FireMonkey : http://img198.imageshack.us/img198/1294/firemonkey...

MIDA - Vcl To FireMonkey converter
This message is no longer available. > {quote:title=Mida FireMonkey wrote:}{quote} > I am here to present the immediate availability of the best converter from VCL to Firemonkey. > > > More than 200 components converted to the nearest component firemonkey. > > I remember that the two technologies are very different, can not ‘exist a true total conversion. but you can get a new project with a few change can be compiled in Firemonkey. > > With the next versions will update the database conversion ( online ), for example when it is available for a real TRi...

MIDA - Vcl To FireMonkey converter
I am here to present the immediate availability of the best converter from VCL to Firemonkey. More than 200 components converted to the nearest component firemonkey. I remember that the two technologies are very different, can not ‘exist a true total conversion. but you can get a new project with a few change can be compiled in Firemonkey. With the next versions will update the database conversion ( online ), for example when it is available for a real TRichEdit under FM, MIDA will convert automatically the old TRichEdit. The time to create MIDA was rather long and complex. ...

Mida Converter
Mida is a complete converter of Embarcadero Delphi and C++ Builder VCL applications to FireMonkey applications. It is able to fully convert over 200 components with more being added in each new release. It fully supports and updates the data modules updating the .pas, .cpp, and .dpr files in both Delphi and C++ Builder. VCL Framework and FireMonkey frameworks are very different and in some cases single click conversions are not possible. But in most cases you can generate a new FireMonkey application with only a few manual changes required. Mida is priced modestly costing less than 2 hou...

Mida Converter
Mida is a complete converter of Embarcadero Delphi and C++ Builder VCL applications to FireMonkey applications. It is able to fully convert over 200 components with more being added in each new release. It fully supports and updates the data modules updating the .pas, .cpp, and .dpr files in both Delphi and C++ Builder. VCL Framework and FireMonkey frameworks are very different and in some cases single click conversions are not possible. But in most cases you can generate a new FireMonkey application with only a few manual changes required. Mida is priced modestly costing less than 2 hou...

Mida Converter
Mida is a complete converter of Embarcadero Delphi and C++ Builder VCL applications to FireMonkey applications. It is able to fully convert over 200 components with more being added in each new release. It fully supports and updates the data modules updating the .pas, .cpp, and .dpr files in both Delphi and C++ Builder. VCL Framework and FireMonkey frameworks are very different and in some cases single click conversions are not possible. But in most cases you can generate a new FireMonkey application with only a few manual changes required. Mida is priced modestly costing less than 2 hou...

Mida Converter
Mida is a complete converter of Embarcadero Delphi and C++ Builder VCL applications to FireMonkey applications. It is able to fully convert over 200 components with more being added in each new release. It fully supports and updates the data modules updating the .pas, .cpp, and .dpr files in both Delphi and C++ Builder. VCL Framework and FireMonkey frameworks are very different and in some cases single click conversions are not possible. But in most cases you can generate a new FireMonkey application with only a few manual changes required. Mida is priced modestly costing less than 2 hou...

ANN: MIDA - Vcl To FireMonkey converter
I am here to present the immediate availability of the best converter from VCL to Firemonkey. More than 200 components converted to the nearest component firemonkey. I remember that the two technologies are very different, can not ‘exist a true total conversion. but you can get a new project with a few change can be compiled in Firemonkey. With the next versions will update the database conversion ( online ), for example when it is available for a real TRichEdit under FM, MIDA will convert automatically the old TRichEdit. The time to create MIDA was rather long and complex. ...

Web resources about - How to convert the Integer representation of VCL.TColor to a FMX.TColor - embarcadero.delphi.firemonkey

Axis–angle representation - Wikipedia, the free encyclopedia
In mathematics, the axis–angle representation of a rotation parameterizes a rotation in a three-dimensional Euclidean space by two values: a ...

ARIA Awards 2015: Matt Okine uses speech to call out lack of female representation in category
The winner of the ARIA for best comedy release has taken a more serious tone to his acceptance speech, highlighting the lack of woman in ...

NSW Libs push to increase female representation but baulk at Howard reforms
The NSW Liberal Party will be required to set targets for the number of women preselected at state and federal seats under a reform package which ...

Jony Ive talks Apple Pencil, calls other tools ‘poor representation of the analog world’
... and Apple Pencil is leading some to change their habits. This, Ive said, is due in large part to every other stylus being a “pretty poor representation ...

Truck buyer’s exclusive dealing class action dismissed for lack of representation - Above the Law
... dealing and monopolization claims were dismissed by the federal district court in Wilmington, Delaware, because the proposed class lacked representation ...

Dyson royal commission: Free up the market for labour representation
Unions are a protected monopoly in a 21st century labour market but there's little reason that monopoly should continue.

Why Australian indigenous representation matters to kids
Melanie Prewett, the Aboriginal writer of award-winning children's book Two Mates, gives her take on indigenous representation in Australian ...

Caught on Tape: Florida GOP's Race-Based Scheme To Dilute Minority Representation
... One . The audio captures Florida Republican state Rep. Janet Adkins at a meeting with the North Florida GOP, plotting to dilute minority representation ...

Michael SavageGovernment Zero: No Culture, No Language, No Borders, No Representation
Michael SavageGovernment Zero: No Culture, No Language, No Borders, No Representation

Tyler Perry talks race, class, representation & Spike Lee with NY Mag
... now?’ Let’s talk about some real issues…There are so many people that society says their stories don’t matter because they’re poor.” Representation: ...

Resources last updated: 1/22/2016 9:44:20 PM