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
 combine vector and image in the pdf
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

srtt

Turkey
24 Posts

Posted - Jun 04 2024 :  10:09:00  Show Profile  Reply
What I want to do is to place the original image behind a vector pdf. so I can see the details better. Can I do this using imagen?
I did it with inkscape. but I don't want to use it. I want to do it with imageen.

sample pdf, original image and pdf I made in inkscape.


orjinal image



traced vector pdf



inkscape

xequte

38610 Posts

Posted - Jun 04 2024 :  20:00:59  Show Profile  Reply
Hi

This is not an easy image to convert because the background is as dark in the bottom left corner as the drawing.

But you could use thresholding, e.g.

  ImageEnView1.Proc.ConvertToBWLocalThreshold( 8, ietMean );




Optionally with some smoothing:

ImageEnView1.Proc.ConvertToBWThreshold( -2 );
  ImageEnView1.IEBitmap.PixelFormat := ie24RGB;
  ImageEnView1.IEBitmap.SetTransparentColors( TColor2TRGB( clWhite ), 0, 0 );
  ImageEnView1.IEBitmap.FeatherAlphaEdges( 1 );
  ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clWhite ); // Convert alpha back to white





Or Edge detection:

ImageEnView1.Proc.EdgeDetect_Sobel();




ImageEnView1.IEBitmap.PixelFormat := ie8g;
  ImageEnView1.IEBitmap.GetIEVisionImage().canny(0. 166, 3 );
  ImageEnView1.IEBitmap.Negative()
;




To draw the result onto another image use:

https://www.imageen.com/help/TIEBitmap.DrawToTIEBitmap.html


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

xequte

38610 Posts

Posted - Jun 04 2024 :  21:48:31  Show Profile  Reply


// Apply a cartoon like vector trace to an image

/// Detect and remove background
ImageEnView1.Proc.ConvertToBWLocalThreshold( 17, ietMeanMinMax );

// Smooth edges?
ImageEnView1.IEBitmap.PixelFormat := ie24RGB;
ImageEnView1.IEBitmap.SetTransparentColors( TColor2TRGB( clWhite ), 0, 0 );
ImageEnView1.IEBitmap.FeatherAlphaEdges( 5 );
ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clWhite ); // Convert alpha back to white

// Darken lines
ImageEnView1.Proc.Contrast( 40 );



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

xequte

38610 Posts

Posted - Jun 05 2024 :  00:35:21  Show Profile  Reply
Hi

I decided to create a helper method to do this. You can email me for the updated source.









Nigel
Xequte Software
www.imageen.com

Go to Top of Page

srtt

Turkey
24 Posts

Posted - Jun 05 2024 :  02:50:23  Show Profile  Reply
Thank you very much.
Sorry for my English.
The main point here was this. I have 2 files in my hand. traced pdf (traced.pdf) and original image (orjinal.bmp) . How do I add (combine) the original image (original.bmp) to the pdf (traced.pdf) file? In other words, how can I open the pdf and place the original image in the background?
Go to Top of Page

xequte

38610 Posts

Posted - Jun 05 2024 :  19:03:01  Show Profile  Reply
Hi

Please see the demo:

\Demos\Other\PDFPageObjects\PDFPageObjects.dpr
https://www.imageen.com/files/demos/run/Other/PDFPageObjects/PDFPageObjects.zip

Which shows how to insert an image into an existing PDF file.

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

srtt

Turkey
24 Posts

Posted - Jun 09 2024 :  17:28:26  Show Profile  Reply
I didn't see it in this demo.
How can I put one of the 2 images on 1 pdf page in front or behind?
BringToFront? and sendtoback?
Go to Top of Page

xequte

38610 Posts

Posted - Jun 09 2024 :  19:23:04  Show Profile  Reply
Please use this method:

// Load our background image
ImageEnView1.IO.LoadFromFile( 'D:\_Testfiles\TestImages\Test2.png' );


// Load our foreground image
bmp := TIEBitmap.Create( 'D:\Temp\Cartoonify1.png' );


// Convert white background to alpha (transparent)
bmp.SetTransparentColors( clWhite, clWhite, 0 );

// Draw foreground image onto background image
bmp.DrawToTIEBitmap( ImageEnView1.IEBitmap, 0, 0 );
bmp.Free();

// Update the ImageEnView
ImageEnView1.Update();



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

srtt

Turkey
24 Posts

Posted - Jun 10 2024 :  02:23:18  Show Profile  Reply
I meant how can I put object[1].bitmap object[5].bitmap or object[2].path, object[].line in the pdf file to the back or front.
Go to Top of Page

xequte

38610 Posts

Posted - Jun 10 2024 :  05:19:13  Show Profile  Reply
Sorry, I'm not following what you are trying to achieve.



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

srtt

Turkey
24 Posts

Posted - Jun 11 2024 :  03:54:52  Show Profile  Reply


This is my 1 page pdf file.
How can I bring the (traced vector) object behind to the front?
Or how can I get the front bitmap image to the back?

How do I do this in pdf?

imaeenview1.pdfviewer.bitmap[0].sendtoback;
Is there a similar command like the command.

Go to Top of Page

xequte

38610 Posts

Posted - Jun 11 2024 :  04:27:09  Show Profile  Reply
Hi

Unfortunately PDFium does not support SendToBack commands or z-order editing.

Your only option would be to:

1. Copy the two objects to TIEBitmaps:

http://www.imageen.com/help/TPdfObject.GetImage.html

2. Remove the objects:

http://www.imageen.com/help/TPdfObjectList.RemoveObject.html

3. Add them back in the correct order:

https://www.imageen.com/help/TPdfObjectList.AddImage.html

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

srtt

Turkey
24 Posts

Posted - Jun 11 2024 :  05:18:17  Show Profile  Reply
ok. thank you for your help
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: