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
 Extracting Image, editing it and setting is back in PDF is not working for me...
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
754 Posts

Posted - Oct 28 2026 :  07:58:49  Show Profile  Reply
Hello,

I am using the following code to find the image object, extract it, apply contrast and then set it back. But I am not getting any result.


procedure TfrmMain.ApplyContrastToTopmostImage;
const
  // Contrast boost applied to the topmost image of the extracted card
  // (range: -100..+100, 0 = no change)
  CONTRAST_AMOUNT = 90.0;
var
  I, TopIdx, TopMost: Integer;
  Obj: TPdfObject;
  bmp: TIEBitmap;
  Applied: Boolean;
begin
  if (ImageEnView1.PdfViewer.Objects = nil) or
     (ImageEnView1.PdfViewer.Objects.Count = 0) then
    Exit;

  Application.ProcessMessages;

  // Find the image object that is visually topmost (smallest Bounds.Top)
  TopMost := MaxInt;
  TopIdx := -1;
  for I := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
  begin
    Obj := ImageEnView1.PdfViewer.Objects[I];
    if (Obj.ObjectType = ptImage) and (Obj.Bounds.Top < TopMost) then
    begin
      TopMost := Obj.Bounds.Top;
      TopIdx := I;
    end;
  end;

  if TopIdx < 0 then
    Exit;

  Application.ProcessMessages;

  // Extract the image, boost contrast and write it back
  bmp := TIEBitmap.Create();
  Applied := False;
  try
    if ImageEnView1.PdfViewer.Objects[TopIdx].GetImage( bmp ) then
    begin
      bmp.Proc.Contrast( CONTRAST_AMOUNT );

      // Store the photo as JPEG to keep the PDF compact
      ImageEnView1.IO.Params.PDF_Compression := ioPDF_JPEG;
      ImageEnView1.IO.Params.JPEG_Quality := 90;

      Applied := ImageEnView1.PdfViewer.Objects[TopIdx].SetImage( bmp );
    end;
  finally
    bmp.Free();
  end;

  if Applied then
    ImageEnView1.PdfViewer.ReloadPage();  // required after changing page images

  UpdateControls( True );
end;


TIA

Yogi Yang

xequte

39591 Posts

Posted - Oct 28 2026 :  18:23:55  Show Profile  Reply
Hi Yogi

What version of ImageEn is this? If it is not v15.4.0, please email me.

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

yogiyang

India
754 Posts

Posted - Oct 29 2026 :  23:32:44  Show Profile  Reply
Yes, it is v15.2.0

Yogi Yang
Go to Top of Page

xequte

39591 Posts

Posted - Oct 30 2026 :  02:46:32  Show Profile  Reply
OK, email me for v15.4.0 to confirm the issue.

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

yogiyang

India
754 Posts

Posted - Nov 02 2026 :  00:57:27  Show Profile  Reply
Hello Nigel,

I just wanted to confirm if this issue is also resolved in the Preview or not.

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=6670

TIA

Yogi Yang
Go to Top of Page

yogiyang

India
754 Posts

Posted - Nov 02 2026 :  01:27:56  Show Profile  Reply
Hello Nigel,

This issue still persist in the new Preview release.

I just tried it out.

I am able to replace the image with another image but color correcting the then apply the image back is not working.

Yogi Yang
Go to Top of Page

xequte

39591 Posts

Posted - Nov 02 2026 :  17:03:52  Show Profile  Reply
Hi Yogi

Your code works for me.

To make it easy to confirm, change the Contrast code to:
bmp.Proc.Negative();

Does the change occur?

Try inspecting (or saving) the bmp during the process to confirm.

Also, are you using the new iepdf32/64.dll in v15.4.0?


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