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
 Watermark

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
wesleybobato Posted - Feb 12 2013 : 12:47:27
Hello There Any Other Better Way to Add logo that I would like to put watermark could help me? Below is the code.

var
Idx, sHeight, sWidth, cWidth, cHeight: Integer;
Source, Dest: TImageEnVect;
I: Integer;
begin
CdsPhotos.First;
for I := 0 to CdsPhotos.RecordCount - 1 do
if CdsPhotos.Fields[2].AsString = 'FOTO' then
begin
Source := TImageEnVect.Create(nil);
Dest := TImageEnVect.Create(nil);
try
Source.IEBitmap.AssignImage(ImgMulti.GetTIEBitmap(CdsPhotos.Fields[1].AsInteger));

Idx:= Source.LayersAdd;
Source.IO.LoadFromFile(FilePath);
Source.ForceALTkey := True;
Source.LayersResizeAspectRatio := TIELayersResizeAspectRatio(iearALTKey);

if (Source.Layers[Idx].Width > Source.Layers[0].Width) or
(Source.Layers[Idx].Height > Source.Layers[0].Height) then
begin // trabalho no tamanho do logotipo...
sWidth := Source.Layers[0].Width * 10 div 100;
sHeight := Source.Layers[0].Height * 10 div 100;
Source.Proc.Resample(sWidth, sHeight, rfLanczos3, True);
end;

cWidth := Source.Layers[0].Width * 15 div 100;
cHeight := Source.Layers[0].Height * 10 div 100;

Source.Layers[Idx].PosX := Source.Layers[0].Width - cWidth;
Source.Layers[Idx].PosY := cHeight;

Source.IO.Params.ImagingAnnot.CopyFromTImageEnVect(Source);

Source.LayersDrawTo(Dest.IEBitmap);
ImgMulti.SelectedImage := CdsPhotos.Fields[1].AsInteger;
ImgMulti.SetIEBitmap(CdsPhotos.Fields[1].AsInteger,Dest.IEBitmap);
finally
CdsPhotos.Next;
FreeAndNil(Source);
FreeAndNil(Dest);
end;
end
else
CdsPhotos.Next;
end;

Thank You.
6   L A T E S T    R E P L I E S    (Newest First)
wesleybobato Posted - Feb 14 2013 : 14:36:59
Hello William Thanks For Your Help May God Bless you
a Big Hug ..
w2m Posted - Feb 14 2013 : 08:50:26
You may download a demo that shows how to make sure the logo is transparent and how to speed up processing here:
https://dl.dropbox.com/u/3695621/Watermark.zip

The key part of the code is shown below:
procedure TForm1.Process1Click(Sender: TObject);
var
  i: integer;
  iLayer, sHeight, sWidth, cWidth, cHeight: Integer;
  iSource, iDest: TImageEnVect;
  iLogo: TImageEnView;
begin
  // if no photo loaded then show warning message and exit
  if ImageEnMView1.ImageCount = 0 then
  begin
    MessageDlg('A photo has not been loaded.  Select Open then try again.', mtWarning, [mbOK], 0);
    exit;
  end;
  Screen.Cursor := crHourGlass;
  try
    // Speed up the conversion by getting the logo before processing
    iLogo := TImageEnView.Create(nil);
    try
      iLogo.IO.LoadFromFile(ApplicationFolder + 'brazil.png'); // load the logo
      iLogo.EnableAlphaChannel := True;
      iLogo.IO.Params.BMP_HandleTransparency := True;
      // the logo is 32-bit with a black background so set the transparent color baised on the
      // bottom left pixel
      iLogo.Proc.SetTransparentColors(iLogo.IEBitmap.Pixels[0,
        iLogo.IEBitmap.Height - 1],
          iLogo.IEBitmap.Pixels[0,
        iLogo.IEBitmap.Height - 1], 0);
      for i := 0 to ImageEnMView1.ImageCount - 1 do
      begin
        iSource := TImageEnVect.Create(nil);
        try
          iDest := TImageEnVect.Create(nil);
          try
            // acquire through the thumbnail image
            iSource.IEBitmap.AssignImage(ImageEnMView1.GetTIEBitmap(i));
            iLayer := iSource.LayersAdd; // add a layer
            // adjust the size of the logo ...
            sWidth := iSource.Layers[0].Width div 10;
            sHeight := iSource.Layers[0].Height div 10;
            // resize the logo in proportion to the image
            iLogo.Proc.Resample(sWidth, sHeight, rfLanczos3, True);
            iSource.IO.Params.BMP_HandleTransparency := True;
            iSource.IEBitmap.Assign(iLogo.IEBitmap); // load the logo into the layer
            // support transparency
            // if bitmaps are used rather than png then handle bitmap transparency
            iSource.IO.Params.BMP_HandleTransparency := True;
            iSource.EnableAlphaChannel := True;
            // set the position of the layer
            cWidth := iSource.Layers[0].Width * 15 div 100;
            cHeight := iSource.Layers[0].Height * 10 div 100;
            iSource.Layers[iLayer].PosX := iSource.Layers[0].Width - cWidth;
            iSource.Layers[iLayer].PosY := cHeight;
            iSource.IO.Params.ImagingAnnot.CopyFromTImageEnVect(iSource);
            iSource.LayersDrawTo(iDest.IEBitmap); // combine the layers
            ImageEnMView1.SelectedImage := 0;
            ImageEnMView1.EnableAlphaChannel := True;
            ImageEnMView1.SetIEBitmap(i, iDest.IEBitmap);
            ImageEnVect1.Update;
          finally
            iDest.Free;
          end;
        finally
          iSource.Free;
        end;
      end;
      // show the first image
      ImageEnVect1.IEBitmap.Assign(ImageEnMView1.GetTIEBitmap(0));
      if Fit1.Checked then
        ImageEnVect1.Fit;
      ImageEnVect1.Update;
    finally
      iLogo.Free;
    end;
  finally
    Screen.Cursor := crDefault;
  end;
end;
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
wesleybobato Posted - Feb 14 2013 : 04:41:38
Hello Friend Thanks for your Attention Picture Below follows a code used as demonstration and
Thanks Again.


unit Unit5;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ieview, iemview, iexShellThumbnails, StdCtrls, imageenview, ievect,
ieopensavedlg, imageenio;

type
TForm5 = class(TForm)
ImageEnMView1: TImageEnMView;
Button1: TButton;
Button3: TButton;
Button2: TButton;
SaveImageEnDialog1: TSaveImageEnDialog;
ImageEnIO1: TImageEnIO;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form5: TForm5;

implementation

uses
hyiedefs;

{$R *.dfm}

procedure TForm5.Button1Click(Sender: TObject);
begin
ImageEnMView1.MIO.LoadFromFile('Cópia de _DSC8113.JPG');
end;

procedure TForm5.Button2Click(Sender: TObject);
begin
if SaveImageEnDialog1.Execute then
begin
ImageEnMView1.SelectedImage := 0;
ImageEnIO1.IEBitmap.Assign(ImageEnMView1.IEBitmap);
ImageEnIO1.SaveToFile(SaveImageEnDialog1.FileName);
end;

end;

procedure TForm5.Button3Click(Sender: TObject);
var
Idx, sHeight, sWidth, cWidth, cHeight: Integer;
Source, Dest: TImageEnVect;
I: Integer;
begin
Source := TImageEnVect.Create(nil);
Dest := TImageEnVect.Create(nil);
try
Source.IEBitmap.AssignImage(ImageEnMView1.GetTIEBitmap(0)); // adquiro imagem atraves do thumbnail.

Idx:= Source.LayersAdd; // ADICIONO CAMADA PARA CARREGAR O LOGOTIPO
Source.IO.LoadFromFile('logo-Brasil.png'); // CARREGO O LOGOTIPO..
Source.ForceALTkey := True;
Source.LayersResizeAspectRatio := TIELayersResizeAspectRatio(iearALTKey);

if (Source.Layers[Idx].Width > Source.Layers[0].Width) or
(Source.Layers[Idx].Height > Source.Layers[0].Height) then
begin // trabalho no tamanho do logotipo...
sWidth := Source.Layers[0].Width * 10 div 100;
sHeight := Source.Layers[0].Height * 10 div 100;
Source.Proc.Resample(sWidth, sHeight, rfLanczos3, True);
end;

cWidth := Source.Layers[0].Width * 15 div 100; // Distancia da Direita para Esquerda
cHeight := Source.Layers[0].Height * 10 div 100; // Altura.. de Baixo para Cima...

Source.Layers[Idx].PosX := Source.Layers[0].Width - cWidth; //direita horizontal.
Source.Layers[Idx].PosY := cHeight; //baixo vertical.

Source.IO.Params.ImagingAnnot.CopyFromTImageEnVect(Source);

Source.LayersDrawTo(Dest.IEBitmap); //faço um união com todas as camadas.
ImageEnMView1.SelectedImage := 0;
ImageEnMView1.SetIEBitmap(0, Dest.IEBitmap);// adiciona a imagem no carrinho atualizada;
finally
FreeAndNil(Source);
FreeAndNil(Dest);
end;
end;

end.



w2m Posted - Feb 13 2013 : 16:56:21
Your video manager could not download... so I could not test this. Unfortunately, this is much more to do than I want to deal with. If you can post the background image and an example watermark images I will look at those and give you some ideas.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
wesleybobato Posted - Feb 13 2013 : 15:04:46
Hello Friend Thanks For Help Follow the Link Below to Download on 4shared Demo Project will be you can help me to improve this process for as many demo images is very slow .... and how to bring transparency in the logo

thank you for your attention a big hug ..

http://www.4shared.com/zip/_OOxpg-X/projet.html?
w2m Posted - Feb 12 2013 : 17:25:42
What does your base bitmap and the watermark bitmap look like? Post some sample images of both.

William Miller