VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 12345678910 ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 08:57:04 03/15/06 Wed
Author: Reini
Subject: Re: ConvertToGray Need convert to Brown (sepia)
In reply to: Dima 's message, "Re: ConvertToGray Need convert to Brown (sepia)" on 12:08:49 02/28/06 Tue

The code works great. Thanks! I've added a Depth property so the sepia filter can be adjusted by the user:

<code>

type
TSepiaTransform = class(TImageTransform)
private
FDepth: Byte;
public
constructor Create;
procedure Apply(const DibGraphic: TDibGraphic); override;
procedure ApplyOnDest(const Source: TDibGraphic; const Dest: TDibGraphic);
property Depth: Byte read FDepth write FDepth default 20;
end;

constructor TSepiaTransform.Create;
begin
Inherited Create;
FDepth := 20;
end;

procedure TSepiaTransform.Apply(const DibGraphic: TDibGraphic);
var
Color: TRGB;
H, W: Integer;
Gray: Integer;
begin
FLastPercent := -1;
FLastPercent := DoProgress(Self,FOnProgress,0,0,100,FLastPercent);
for H := 0 to DibGraphic.Height - 1 do
begin
FLastPercent := DoProgress(Self,FOnProgress,H,0,DibGraphic.Height - 1,FLastPercent);
for W := 0 to DibGraphic.Width - 1 do
begin
Color := DibGraphic.RGB[W,H];
Gray := (Color.Red + Color.Green + Color.Blue) div 3; //CONVERT TO GRAY
Color.Blue := Gray;
Color.Green := Gray + Depth;
Color.Red := Gray + (Depth * 2);
if Color.Red < (Depth * 2) then
Color.Red := 255;
if Color.Green < Depth then
Color.Green := 255;
DibGraphic.RGB[W,H] := Color;
end;
end;
FLastPercent := DoProgress(Self,FOnProgress,100,0,100,FLastPercent);
end;

procedure TSepiaTransform.ApplyOnDest(const Source: TDibGraphic; const Dest: TDibGraphic);
begin
Dest.Assign(Source);
Apply(Dest);
end;
</code>

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.