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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to crop the image to the painted rectangle?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
klinikaxp Posted - Aug 28 2017 : 09:27:23
I have a device, which enables to draw a signature using special pen.
It is stored on the hard drive as a bitmap. However stored area is big and signature takes only small part of it. Is there any way to easily crop only part of on image, which contains the signature? It could be something like procedure TImageEn.ReduceToPainted (Margins:Integer; BackColor:TColor=clWhite);
or conversion function:
function ReduceToPainted (src:SrcBitmap; Margins:Integer; BackColor:TColor=clWhite) : TBitmap;

Maybe there is something like this already implemented?
3   L A T E S T    R E P L I E S    (Newest First)
klinikaxp Posted - Aug 28 2017 : 17:31:13
Thank you for quick answer and functionality - it was exactly what I was looking for!
xequte Posted - Aug 28 2017 : 17:02:30
Also, have you tried the auto-cropping methods, such as:

https://www.imageen.com/help/TImageEnProc.AutoCrop.html


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Aug 28 2017 : 10:27:16
There are no functions that I am aware of that will select the area around the text for cropping. If the signature image background is white and the text is black then the following will work quite well:
ImageEnView1.SelectColors(TColor2TRGB(clBlack));
ImageEnView1.Proc.CropSel();
ImageEnView1.Deselect;

If the text color is blue then replace clBlack with clBlue.
In my tests, this reduced a 256x256 signature image to 115x115.

Also if the location of the signature is in the same location in your images you can just set the selection to the proper dimensions and then crop the selection:
{ Figure out the area to select and add those values to the following}
ImageEnView1.Select(100, 900, 150, 100); 
{ Crop  the selection }
ImageEnView1.Proc.CropSel();
ImageEnView1.Deselect;

You could also try:
ImageEnView1.Select(100, 900, 150, 100);
ImageEnView1.SaveSelectionToFile('Signature');

Then when you want to crop the image call LoadSelectionFromFile and crop:
ImageEnView1.LoadSelectionFromFile('Signature');
ImageEnView1.Proc.CropSel();
ImageEnView1.Deselect;

Also see:
procedure SaveSelection and RestoreSelection.
Description
Adds the current selection to the stack (selections list).

Example
ImageEnView1.Select(10, 10, 100, 100);
ImageEnView1.SaveSelection;
ImageEnView1.Select(200, 200, 150, 150);
ImageEnView1.SaveSelection;
ImageEnView1.Deselect;

ImageEnView1.RestoreSelection; // reload 200,200,150,150
..
ImageEnView1.RestoreSelection; // reload 10,10,100,100

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