AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Colorpanel berechnen
Thema durchsuchen
Ansicht
Themen-Optionen

Colorpanel berechnen

Ein Thema von Pr0g · begonnen am 13. Nov 2004 · letzter Beitrag vom 20. Nov 2004
 
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#8

Re: Colorpanel berechnen

  Alt 13. Nov 2004, 14:31
Ist ganz einfach das ganze. Dax hasts schon richtig erklärt wies geht:
Delphi-Quellcode:
function GetBlendColor(Basecolor: TColor; Blendcolor: TColor; BlendIntensity: Byte=127): TColor;
function GetValueButMax(AValue: Real; Max: Byte): Byte;
begin
  if AValue > max then result := max else result := trunc(AValue);
end;
type
  TMyColor = record
    red: Byte;
    green: Byte;
    blue: Byte;
  end;
var LF1, LF2: TMyColor;
begin
  LF1.red := GetRValue(Basecolor);
  LF1.green := GetGValue(Basecolor);
  LF1.blue := GetBValue(Basecolor);
  LF2.red := (LF1.red * (255-BlendIntensity) + GetRValue(Blendcolor) * BlendIntensity) div 255;
  LF2.green := (LF1.green * (255-BlendIntensity) + GetGValue(Blendcolor) * BlendIntensity) div 255;
  LF2.blue := (LF1.blue * (255-BlendIntensity) + GetBValue(Blendcolor) * BlendIntensity) div 255; result := rgb(LF2.red, LF2.green, LF2.blue);
end;

procedure FillWithColor(ABitmap: TBitmap; ABaseColor: TColor; ADestColor1: TColor = clWhite; ADestColor2: TColor = clBlack);
var LCountX, LCountY: Integer;
    LFactorX, LFactorY: Extended;
    LTmpColor1, LTmpColor2: TColor;
begin
  LFactorX := 255 / ABitmap.Width;
  LFactorY := 255 / ABitmap.Height;
  for LCountX := 0 to ABitmap.Width - 1 do
  begin
    LTmpColor1 := GetBlendColor(ADestColor1, ABaseColor, Trunc(LCountX * LFactorX));
    for LCountY := 0 to ABitmap.Height do
    begin
      LTmpColor2 := GetBlendColor(LTmpColor1, ADestColor2, Trunc(LCountY * LFactorY));
      ABitmap.Canvas.Pixels[LCountX, LCountY] := LTmpColor2;
    end;
  end;
end;
damit das ganze wie in deinem beispiel aussieht das ganze so aufrufen:

Delphi-Quellcode:
  Image1.Picture.Bitmap.Width := Image1.Width;
  Image1.Picture.Bitmap.Height := Image1.Height;
  FillWithColor(Image1.Picture.Bitmap, RGB(0, 128, 255));
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  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 03:10 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