AGB  ·  Datenschutz  ·  Impressum  







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

Better sepia wanted

Ein Thema von WojTec · begonnen am 26. Jan 2010 · letzter Beitrag vom 29. Jan 2010
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Better sepia wanted

  Alt 26. Jan 2010, 14:56
Hi. I'm looking for better method for sepialize image. Currently I'm using "open source" (similar implementation available everywhere in many languages) method:

Delphi-Quellcode:
Bits.R := (Bits.R + Bits.G + Bits.B) div 3;
Bits.G := Bits.R;
Bits.B := Bits.R;

Inc(Bits.R, AFactor * 2);
Inc(Bits.G, AFactor);

if Bits.R < (AFactor * 2) then Bits.R := 255;
if Bits.G < (AFactor) then Bits.G := 255;
I thought, that result is good till I saw sepialized image from PSP.

Do you know better algorithm?
  Mit Zitat antworten Zitat
Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.429 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: Better sepia wanted

  Alt 28. Jan 2010, 10:46
try it out
Delphi-Quellcode:
type
  TBGR = packed record
    B, G, R: Byte;
  end;

procedure RenderColor(ABitmap: TBitmap; NewHue, NewSaturation: Word);
var
  Hue, Luminance, Saturation: Word;
  p: ^TBGR;
  c: TColor;
  x, y: Integer;
begin
  // NewHue := 36;
  // NewSaturation := 64;

  with ABitmap do
  begin
    PixelFormat := pf24Bit;
    for y := 0 to Height - 1 do
    begin
      p := ScanLine[y];
      for x := 0 to Width - 1 do
      begin
        c := RGB(p^.R, p^.G, p^.B);
        ColorRGBToHLS(c, Hue, Luminance, Saturation);
        c := ColorHLSToRGB(NewHue, Luminance, NewSaturation);
        p^.B := GetBValue(c);
        p^.G := GetGValue(c);
        p^.R := GetRValue(c);
        Inc(p);
      end;
    end;
  end;
end;
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: Better sepia wanted

  Alt 29. Jan 2010, 17:40
Working quite good, thanks
Could you tell what to do to get more grey, like in version in post #1?

PS: I early did't known about ColorRGBToHLS() and ColorHLSToRGB(). What are maximum values for HLS? The same as in Windows color dialog, mean 239, 240, 240? And yet another stupid question: Delphi HLS is the same like HSL (hue, saturation, lightness)?
  Mit Zitat antworten Zitat
Antwort Antwort


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 23:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz