Results 1 to 2 of 2

Thread: Converting pSDL_COLOR to TColor/Cardinal and back

  1. #1

    Converting pSDL_COLOR to TColor/Cardinal and back

    How do i convert pSDL_Color to TColor or Cardinal, and how do i convert Cardinal/TColor to pSDL_COLOR?
    Are there any functions, maybe even in SDL which i can use?

    Thanks for help.

  2. #2
    If by Cardinal, you mean a color in $RRGGBB format, then just (*, +) or (shl, or) the components of sdl's color.
    Code:
    Function SDL_ColorToUInt(Col:PSDL_Color):Longword;
       begin Exit((Col^.R shl 16) or (Col^.G shl 8) or (Col^.B)) end; 
    
    Function Make_PSDL_Color(Num:LongWord):PSDL_Color;
       Var Col:PSDL_Color;
       begin New(Col);
       Col^.R:=Num shr 16;
       Col^.G:=Num shr 8;
       Col^.B:=Num;
       Exit(Col)
       end;

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL