ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Values for real sepia?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
flatserv Posted - Nov 22 2012 : 02:41:46
Hi,

i want to convert my Image into sepia, currently i use

ImageEnView1.Proc.Colorize(40, 50, 1.1);
ImageEnView1.Proc.IntensityRGBall(0,0,78);

Because there is no real "ConvertToSepia" function and my values (see above) are not perfect: Does anyone have better values? Or maybe ideas how to convert into better sepia?

Best regards
2   L A T E S T    R E P L I E S    (Newest First)
flatserv Posted - Nov 23 2012 : 08:26:27
Works fine, many thanks!
w2m Posted - Nov 23 2012 : 07:47:54
Someone may have an ImageEn method to create Sepia effect, but here is another way:
function BmpToSepia(const ABitmap: TBitmap; ADepth: Integer): boolean;
//This function adds a sepia effect to a bitmap.
//Adepth sets the colour intensity of the red-brown color
//Greater ADepth values set a higher intensity.
//Usually ADepth values from 35-75 produce the best effect
//To create a greyscale effect, set ADepth to 0
var
  iColor: longint;
  iColor2: longint;
  r, g, b, rr, gg: byte;
  iWidth, iHeight: Integer;
begin
  Screen.Cursor := crHourGlass;
  try
    Result := False;
    begin
      for iHeight := 0 to ABitmap.Height do
      begin
        for iWidth := 0 to ABitmap.Width do
        begin
          //first convert the bitmap to greyscale
          iColor := ColorToRGB(ABitmap.Canvas.Pixels[iWidth, iHeight]);
          r := GetRValue(iColor);
          g := GetGValue(iColor);
          b := GetBValue(iColor);
          iColor2 := (r + g + b) div 3;
          ABitmap.Canvas.Pixels[iWidth, iHeight] := RGB(iColor2, iColor2, iColor2);
          //then convert it to sepia
          iColor := colortorgb(ABitmap.Canvas.Pixels[iWidth, iHeight]);
          r := GetRValue(iColor);
          g := GetGValue(iColor);
          b := GetBValue(iColor);
          rr := r + (ADepth * 2);
          gg := g + ADepth;
          if rr<=((ADepth * 2) - 1) then
            rr := 255;
          if gg<=(ADepth - 1) then
            gg := 255;
          ABitmap.Canvas.Pixels[iWidth, iHeight] := RGB(rr, gg, b);
        end;
        Result := True;
      end;
    end;
  finally
    Screen.Cursor := crDefault;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  iDepth: Integer;
begin
  ImageEnView1.Proc.SaveUndoCaptioned('Sepia ' + IntToStr(ImageEnView1.Proc.UndoCount));
  Undo1.Hint := 'Sepia ' + IntToStr(ImageEnView1.Proc.UndoCount);
  iDepth := 3;
  iDepth := StrToIntDef(InputBox('Blur', 'Enter Sepia Level, IntToStr(iDepth)), 1);
  BmpToSepia(ImageEnView1.Bitmap, iDepth);
  ImageEnView1.Update;
  Undo1.Enabled := ImageEnView1.Proc.CanUndo;
  ImageEnView1.Bitmap.Modified := True;
end;


William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html