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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Water mark images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Sep 07 2012 :  05:27:45  Show Profile  Reply
I want to water mark images with text entered by user.

How can I do this.

I have attached a sample showing what I want to achieve.

TIA

Yogi Yang




Yogi Yang

w2m

USA
1990 Posts

Posted - Sep 07 2012 :  09:05:09  Show Profile  Reply
Hi Yogi:

Try this:

uses ImageEnProc, HYIEutils, HYIEdefs;

procedure IETextOut(Canvas: TCanvas; x, y: integer; angle: integer; const Text: string);
var
  LogFont: TLogFont;
begin
  with Canvas do
  begin
    GetObject(Font.Handle, SizeOf(TLogFont), @LogFont);
    LogFont.lfEscapement := angle * 10;
    LogFont.lfQuality := NONANTIALIASED_QUALITY;
    LogFont.lfWeight := FW_BOLD;
    Font.Handle := CreateFontIndirect(LogFont);
    TextOut(x, y, Text);
    DeleteObject(Font.Handle);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnView1.EnableAlphaChannel := True;
  ImageEnView1.LayersSync := True;
end;

procedure TForm1.Watermark1Click(Sender: TObject);
var
  i: integer;
  j: integer;
  iLayer: integer;
  iSpacing: integer;
  iText: string;
  iRows: integer;
begin
  Screen.Cursor := crHourGlass;
  try
    iLayer := ImageEnView1.LayersAdd;
    ImageEnView1.Proc.Fill(CreateRGB(255, 255, 255));
    ImageEnView1.Bitmap.Canvas.Font.Name := 'Arial';
    ImageEnView1.Bitmap.Canvas.Font.Height := 25;
    ImageEnView1.Bitmap.Canvas.Font.Color := clGray;
    for i := 0 to 60 do
      iText := iText + '     ' + Text1.Text;
    iRows := 100;
    for j := 0 to iRows do
    begin
      iSpacing := 150;
      iSpacing := iSpacing * j;
      IETextOut(ImageEnView1.Bitmap.Canvas, -60, iSpacing, 45, iText); // draw text on second layer
    end;
    // remove the white, making it as transparent
    ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
    ImageEnView1.LayersMergeAll;
    ImageEnView1.Update;
  finally
    Screen.Cursor := crDefault;
  end;
end;


I am sure this could be improved and optimised, but it seems to give you what you are looking for.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

yogiyang

India
727 Posts

Posted - Sep 10 2012 :  07:43:48  Show Profile  Reply
Hello William,

Thanks for the solution.


Yogi Yang
Go to Top of Page

giancarlo

Italy
65 Posts

Posted - Sep 19 2016 :  13:37:28  Show Profile  Reply
just a fix (for batch use and IE6.x):


procedure TForm1.Watermark1Click(Sender: TObject);
var
  i: integer;
  j: integer;
  iLayer: integer;
  iSpacing: integer;
  iText: string;
  iRows: integer;
begin
  Screen.Cursor := crHourGlass;
  try
    iLayer := ImageEnView1.LayersAdd;
    ImageEnView1.Proc.Fill(CreateRGB(255, 255, 255));
    ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
    ImageEnView1.IEBitmap.Canvas.Font.Height := 25;
    ImageEnView1.IEBitmap.Canvas.Font.Color := clGray;
    iText:='';
    for i := 0 to 60 do
      iText := iText + '     ' + Text1.Text;
    iRows := 100;
    for j := 0 to iRows do
    begin
      iSpacing := 150;
      iSpacing := iSpacing * j;
      IETextOut(ImageEnView1.IEBitmap.Canvas, -60, iSpacing, 45, iText); // draw text on second layer
    end;
    // remove the white, making it as transparent
    ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
    ImageEnView1.LayersMergeAll;
    ImageEnView1.Update;
  finally
    Screen.Cursor := crDefault;
  end;
end;
Go to Top of Page

abbasiali

5 Posts

Posted - Sep 20 2016 :  14:01:48  Show Profile  Reply
Hi

Which code I most be write for print watermark with above procedure for image?

Best regards

Ali Abbasi
Go to Top of Page

xequte

38615 Posts

Posted - Sep 22 2016 :  12:13:09  Show Profile  Reply
Sorry, are you having difficulty with the cod above? In what way?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

abbasiali

5 Posts

Posted - Sep 23 2016 :  03:55:54  Show Profile  Reply
Hi

Please help me I call above Watermark1Click procedure and I can not call it procedure!

I cannot make a watermark in a image with it procedure.
For call watermark which I most write code for watermark "this is DEMO version"?


Best regards

Ali Abbasi
Go to Top of Page

xequte

38615 Posts

Posted - Sep 23 2016 :  11:42:43  Show Profile  Reply
Hi Ali

If Text1.Text = 'this is DEMO version'

Then the code above should work fine for you.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

abbasiali

5 Posts

Posted - Sep 23 2016 :  15:43:54  Show Profile  Reply
Hi Nigel

Watermark1Click(................);
Please help me for arguments for it procedure for make similar Yogi Yang image.



Best regards

Ali Abbasi
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 23 2016 :  15:56:55  Show Profile  Reply
I tested the code here and found it functions correctly. What problem are you having? How does it not work? Show the code you are using.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

abbasiali

5 Posts

Posted - Sep 23 2016 :  16:14:32  Show Profile  Reply
Hi Bill

Sorry, I Found my problem and fixed my problem.
I think "procedure TForm1.Watermark1Click(Sender: TObject);" is procedure which working with "procedure IETextOut(Canvas: TCanvas; x, y: integer; angle: integer; const Text: string);"!
Your sample is good and it was my mistake.



Best regards

Ali Abbasi
Go to Top of Page

john_siggy@yahoo.com

USA
158 Posts

Posted - Nov 27 2016 :  18:28:14  Show Profile  Reply
I tried drawing text at an angle and it only worked on empty black images. I have a TImageEnVect being video refreshed in the NewFrame event of an TImageEnMView. The code is:

ImageEnVect1.IEBitmap.Assign(ImageEnMView1.GetTIEBitmap(idx));
ImageEnVect1.Update;

Cant see the text over the image;

Thanks
Go to Top of Page

xequte

38615 Posts

Posted - Nov 28 2016 :  03:56:04  Show Profile  Reply
Hi

So you draw the watermark after the NewFrame event?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

john_siggy@yahoo.com

USA
158 Posts

Posted - Nov 28 2016 :  14:07:45  Show Profile  Reply
Thank you for your excellent response. The watermark code works well but is very slow even putting out one line: "Demo Program",

Seems adding a layer and then merging layers is too slow. Is there some way to use IETextOut to the bitmap more directly.

Thanks again,

John
Go to Top of Page

xequte

38615 Posts

Posted - Nov 29 2016 :  14:05:40  Show Profile  Reply
Hi John

Yes, you should be using the newer: ImageEnView1.Proc.TextOut:

http://www.imageen.com/help/TImageEnProc.TextOut.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: