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
 Preserving Exif tags
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yeohray2

Malaysia
106 Posts

Posted - Nov 16 2021 :  09:13:11  Show Profile  Reply
Hi, not sure if this is the right way, but I'm trying to preserve the Exif tags after adding an image layer. Currently, I'm saving and loading the params to a stream like this:

  procedure ApplyImageOverlay(const ImageFileName: string);
  var
    AStream: TMemoryStream;
  begin
    if FileExists(ImageFileName) then
    begin
      AStream := TMemoryStream.Create;
      try
        AView.IO.Params.SaveToStream(AStream);

        LayerIndex := AView.LayersAdd(ImageFileName);
        AView.Layers[LayerIndex].Opacity := 0.5;

        AStream.Position := 0;
        AView.IO.Params.LoadFromStream(AStream);
      finally
        AStream.Free;
      end;
    end;
  end;


Is this the correct way? Thanks.

xequte

38615 Posts

Posted - Nov 17 2021 :  01:11:26  Show Profile  Reply
Hi

AView.IO.Params is the params of the current layer (or the background layer if you have not yet added any layers).

So, the code above assigns the parameters of the current layer to that of the new layer (the loaded image). It does not replace the params of the original layer, which should not change when loading a new layer.

Can you let me know more about what you are looking to achieve?

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

yeohray2

Malaysia
106 Posts

Posted - Nov 17 2021 :  01:59:29  Show Profile  Reply
I should have mentioned that after adding the image layer, I did try to set LayersCurrent := 0 to retrieve the Exif values, but it was all empty e.g.

AValue := AView.IO.Params.EXIF_Make;
OutputDebugString(PWideChar(AValue)); // has the correct value

ApplyImageOverlay('overlay.png'); // the function I posted earlier

AView.LayersCurrent := 0;

AValue := AView.IO.Params.EXIF_Make;
OutputDebugString(PWideChar(AValue)); // is empty if I don't save and load the params in ApplyImageOverlay

What I'm trying to do is to place a watermark-like image using a layer over the original image, then read the Exif values. I can't read first then apply the overlay because of some other requirements.

Thanks in advance.

Ray
Go to Top of Page

xequte

38615 Posts

Posted - Nov 23 2021 :  00:25:05  Show Profile  Reply
Hi Ray

Can you send me a simple demo that reproduces the issue?

With regard to your query, a simpler method to pass the params between objects is:

var
  params: TIOParams;
begin
  params := TIOParams.Create();
  params.Assign( AView.IO.Params );

  ... Do something that affects the params???
 
  AView.IO.Params.Assign( params );
  params.Free;
end;


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

xequte

38615 Posts

Posted - Nov 25 2021 :  16:18:59  Show Profile  Reply
Hi Ray

So, as it turns out any loading of image layers become the params in TImageEnView by default.

There are two ways to maintain the existing params.

1. Store the params in the TIEBitmap object:

var
  ImageHeight, ImageWidth, LayerIndex: Integer;
begin
  viewMain.LockUpdate;
  viewMain.LayersClear();

  // For Layer 0 use the params of the bitmap, rather than the embedded TImageEnIO
  viewMain.IEBitmap.ParamsEnabled := True;

  viewMain.IO.LoadFromFile('SAM_4783.JPG');
  ImageHeight := viewMain.IEBitmap.Height;
  ImageWidth  := viewMain.IEBitmap.Width;
  viewMain.Fit();

  Log('Loading image');
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);

  Log('Loading overlay');
  LayerIndex := viewMain.LayersAdd('overlay.png');
  viewMain.Layers[LayerIndex].Width  := ImageWidth;
  viewMain.Layers[LayerIndex].Height := ImageHeight;
  viewMain.Layers[LayerIndex].Opacity := 0.5;

  viewMain.UnlockUpdate;

  viewMain.LayersCurrent := 0;
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);
end;


2. Store desired params in an object and assign them back after loading:

var
  ImageHeight, ImageWidth, LayerIndex: Integer;
  params: TIOParams;
begin
  params := TIOParams.Create();
  viewMain.LockUpdate;

  viewMain.IO.LoadFromFile('SAM_4783.JPG');
  ImageHeight := viewMain.IEBitmap.Height;
  ImageWidth  := viewMain.IEBitmap.Width;
  viewMain.Fit();

  // Store image params
  params.Assign( viewMain.IO.Params );
  Log('Loading image');
  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);

  Log('Loading overlay');
  LayerIndex := viewMain.LayersAdd('overlay.png');
  viewMain.Layers[LayerIndex].Width := ImageWidth;
  viewMain.Layers[LayerIndex].Height := ImageHeight;
  viewMain.Layers[LayerIndex].Opacity := 0.5;

  viewMain.UnlockUpdate;

  viewMain.LayersCurrent := 0;

  // Retore image params
  viewMain.IO.Params.Assign( params );

  Log('EXIF_DateTime: ' + viewMain.IO.Params.EXIF_DateTime);
  params.Free;
end;



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

yeohray2

Malaysia
106 Posts

Posted - Nov 26 2021 :  11:08:49  Show Profile  Reply
Noted, Nigel, thanks.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: