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
 Watermarking does not work on all PCs. Why?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - Jan 19 2022 :  00:25:39  Show Profile  Reply
Hello,

We are facing a very wired experience in our software. We have create a demo version of our software in which we are watermarking each output (image).

Here is the code we are using for watermarking.

procedure WaterMarkImage(ieTemp: TImageEnView);
var
  i: integer;
  j: integer;
  iLayer: integer;
  iSpacing: integer;
  iText: string;
  iRows: integer;
begin
  //Exit;
  Screen.Cursor := crHourGlass;
  ieTemp.LockUpdate;
  try
    ieTemp.DeSelect;
    iLayer := ieTemp.LayersAdd;
    ieTemp.Proc.Fill(CreateRGB(255, 255, 255));
    ieTemp.IEBitmap.Canvas.Font.Name := 'Arial';
    ieTemp.IEBitmap.Canvas.Font.Height := 45;
    ieTemp.IEBitmap.Canvas.Font.Color := clGray;
    iText:='';
    for i := 0 to 60 do
      iText := iText + '  You are using Demo Version...' ;
    iRows := 100;
    for j := 0 to iRows do
    begin
      iSpacing := 150;
      iSpacing := iSpacing * j;
      IETextOut(ieTemp.IEBitmap.Canvas, -60, iSpacing, 45, iText); // draw text on second layer
    end;
    // remove the white, making it as transparent
    ieTemp.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
    ieTemp.LayersMergeAll;
    ieTemp.Update;
  finally
    ieTemp.UnLockUpdate;
    Screen.Cursor := crDefault;
  end;
end;


We are calling this procedure to apply watermark to image when the user save the image as well as when the user exports the image.

But this code does not run on every PC. On some PCs the code just gets skipped and there are no watermarks in the image saved or exported.

Any ideas as to what must be the problem here and how to solve it?

Another thing is that this routine is taking a hell of a long time. Can we speed this up?

TIA

Yogi Yang

xequte

38179 Posts

Posted - Jan 19 2022 :  21:11:57  Show Profile  Reply
Hi Yogi

I can't see anything in the code that should cause it to fail. Though, why are you texting out to an image layer, rather than just drawing directly to the ieTemp.IEBitmap.Canvas (without an extra layer)? (or using a TIETextLayer).



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yogiyang

India
725 Posts

Posted - Jan 19 2022 :  23:52:13  Show Profile  Reply
Hello Nigel,

Actually this very old code that I have been using for quite some time.

It was working faultlessly for many years now. But recently this has started giving problems.

What alternative should I use instead of current code?

TIA

Yogi Yang
Go to Top of Page

xequte

38179 Posts

Posted - Jan 20 2022 :  02:11:00  Show Profile  Reply
Hi Yogi

Why not just (on layer 0):

ieTemp.IEBitmap.Canvas.BackgroundStyle := bsClear;
ieTemp.IEBitmap.Canvas.TextOut( ... );

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yogiyang

India
725 Posts

Posted - Jan 29 2022 :  00:39:19  Show Profile  Reply
Hello,

Probably I have managed to isolate the problem.

And the problem is that this code does not work under Win7 32 as well as 64 Bit. Again this works in Win10!

If I install older version of IE 9.x and compile the software it works in Win7 but after upgrading to 10.x it does not work!!

Nigel can you please look into this and help me out.

TIA

Yogi Yang
Go to Top of Page

xequte

38179 Posts

Posted - Jan 30 2022 :  18:22:09  Show Profile  Reply
Hi Yogi

I'm afraid I don't have a Win7 machine for testing. Are you saying that the method above WaterMarkImage() fails in a blank project on Win7?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yogiyang

India
725 Posts

Posted - Feb 01 2022 :  00:49:27  Show Profile  Reply
Hello Nigel,

The WaterMarkImage() fails in a blank project also.

This problem is reproducible. Please check attached project.

TIA

attach/yogiyang/20222104916_WaterMarkSample.zip
55.22 KB

Yogi Yang
Go to Top of Page

xequte

38179 Posts

Posted - Feb 01 2022 :  20:30:37  Show Profile  Reply
Hi Yogi

It works when I test it here, though I don't have Windows 7. What line is it crashing on?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yogiyang

India
725 Posts

Posted - Feb 02 2022 :  00:08:19  Show Profile  Reply
Hello Nigel,

The biggest problem is that it is not crashing!

The WaterMarkImage procedure just does not run on Windows7!

Can you please install Win7 in a VM like VBox and check it?

You can get one from MS official web site here: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

TIA

Yogi Yang
Go to Top of Page

xequte

38179 Posts

Posted - Feb 02 2022 :  16:01:59  Show Profile  Reply
Hi Yogi

Your code doesn't really use ImageEn other than for setting the transparency, which is not needed because you can just set Canvas.Brush.Style to bsClear.

Here is your code with ImageEn not used:


procedure TForm1.WaterMarkImage(ieTemp: TImageEnView);
var
  i: integer;
  j: integer;
  iSpacing: integer;
  iText: string;
  iRows: integer;
begin
  Screen.Cursor := crHourGlass;
  ieTemp.LockUpdate;
  try
    ieTemp.Deselect;
    ieTemp.IEBitmap.Canvas.Font.Name := 'Arial';
    ieTemp.IEBitmap.Canvas.Font.Height := 45;
    ieTemp.IEBitmap.Canvas.Font.Color := clGray;
    ieTemp.IEBitmap.Canvas.Brush.Style := bsClear;
    iText:='';
    for i := 0 to 60 do
      iText := iText + 'Demo Version...' ;
    iRows := 100;
    for j := 0 to iRows do
    begin
      iSpacing := 150;
      iSpacing := iSpacing * j;
      IETextOut(ieTemp.IEBitmap.Canvas, -60, iSpacing, 45, iText); // draw text on second layer
    end;
    ieTemp.Update;
  finally
    ieTemp.UnLockUpdate;
    Screen.Cursor := crDefault;
  end;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yogiyang

India
725 Posts

Posted - Feb 05 2022 :  06:21:46  Show Profile  Reply
Hello Nigel,

Thank you very much for the code sample.

Your code is working in WIn7.

TIA

Yogi Yang
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: