Results 1 to 4 of 4

Thread: ColorToRGB in 16 bits TColor

  1. #1

    ColorToRGB in 16 bits TColor

    Hi

    I need convert a 16bits color to RGB.

    I have this code:
    [pascal]
    ColorPixel := DXImageList.Items[1].PatternSurfaces[0].Pixel[X,Y];
    R := GetRValue(ColorPixel);
    G := GetGValue(ColorPixel);
    B := GetBValue(ColorPixel);
    [/pascal]

    ColorPixel := ColorToRGB(DXImageList.Items[1].PatternSurfaces[0].Pixel[X,Y]); --> same results.


    if Windows are in 32bits color work fine, but when Windows are in 16bits color not work fine, Blue always is 0 and Red and Green ara more value:

    Example:
    in 32 bits color one pixel:
    Results:
    ColorPixel = 9005609 --> 896A29
    R = 41 --> 29
    G = 106 --> 6A
    B = 137 --> 89

    in 16 bits color (same pixel)
    Results:
    ColorPixel = 35653 --> 8B45
    R = 69
    G = 139
    B = 0

    Can I convert 16 bits color to 24 bits color ?

    Thanks
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  2. #2

    ColorToRGB in 16 bits TColor

    Solved:

    [pascal]function RGBTo16bit(R,G,B: Byte): Integer;
    begin
    Result:= ((B shr 3) shl 11) + ((G shr 2) shl 5) + (R shr 3);
    end;[/pascal]


    [pascal]function ToRGB(Color: Integer): Integer;
    begin
    Result:= ((Color and $F800) shl + ((Color and $7E0) shl 5) +
    ((Color and $1F) shl 3)
    end;[/pascal]

    Kotai. :roll:
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  3. #3

    ColorToRGB in 16 bits TColor

    In 16 bit there's even a 5551 (1 bit alpha) format, you need code for that one ?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #4

    ColorToRGB in 16 bits TColor

    No, thanks work fine.

    6 bits for green and 5 for red and blue.

    Kotai. :roll:
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

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
  •