AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Farben nach RGB unrechnen?

Ein Thema von smart · begonnen am 15. Jan 2011 · letzter Beitrag vom 16. Jan 2011
 
hboy

Registriert seit: 16. Jan 2004
364 Beiträge
 
#5

AW: Farben nach RGB unrechnen?

  Alt 15. Jan 2011, 10:53
Delphi-Quellcode:
type TRGBColor = packed record
  case Integer of
    1 : (col: Cardinal);
    2 : (chans: Array[0..3] of byte);
end;

function AsRGB(color: TColor; DC: HDC = 0): TRGBColor;
var
  rgbc: TRGBColor absolute color;
  entry: PALETTEENTRY;
const
  cpSystemPalette = $00;
  cpActingPalette = $01;
  cpLogicalPalette = $02;
  cpGenericPalette = $08;
  cpNoColor = $1F;
  cpDefaultColor = $20;
  cpSystemColor = $FF;
begin
  case rgbc.chans[3] of
    cpGenericPalette, cpLogicalPalette:
      begin
        result.col := (rgbc.col and $00FFFFFF);
      end;

    cpNoColor, cpDefaultColor :
      begin
        result.col := rgbc.col;
      end;

    cpActingPalette :
      begin
        if (GetDeviceCaps(DC,RASTERCAPS) and RC_PALETTE) <> 0 then
        begin
          if 1 = GetPaletteEntries( GetCurrentObject(DC, OBJ_PAL),
                                    rgbc.chans[0], 1, entry) then
          begin
            result.col := $00000000;
            result.chans[0] := entry.peRed;
            result.chans[1] := entry.peGreen;
            result.chans[2] := entry.peBlue;
          end;
        end
        else
          result.col := PaletteIndex(rgbc.chans[0]);
      end;

    cpSystemPalette :
      begin
        result.col := PaletteIndex(rgbc.chans[0]);
      end;

    cpSystemColor :
      begin
        result.col := GetSysColor(rgbc.chans[0]);
      end;

  end;
end;
Soweit ohne Gewähr. Bitte vervollständigen
Power is nothing without TControl

Geändert von hboy (15. Jan 2011 um 11:45 Uhr) Grund: iterativ von Fehlern befreit ;-)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:46 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz