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
 Cropping Fail

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
skippix Posted - Jun 28 2014 : 04:23:53
I have modeled off the cropping demo, but am not getting the results I want.
This is what I draw:


And this is what I get:


Using this code:
procedure TctHelpImageInventoryBuilder.btnSaveImageFileClick(Sender: TObject);
const
  JPEG_FILTER_INDEX = 3;   // 5 for JPEG types
var
  rc: TRect;
  destFile: string;
begin
  destFile := ctutils.GenUniqueFilename(sourceFile)
  if destFile <> '' then
    begin
    // get cut rectangle
      with ImageEnView1 do
        rc := Rect(SelX1, SelY1, SelX2, SelY2);
    // apply lossless cut and save
      JpegLosslessTransform(sourceFile, destFile, jtCut, false, jcCopyAll, rc);
      if (ckbDeselectOnSave.Checked) then
        ImageEnView1.DeSelect;
      Talk (lblTalk, 'File saved to: ' + destFile);
    end
  else
    Talk (lblTalk, 'File not saved');
end;


What am I missing? I really need this to be WYSIWYG.

Thanks!
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jul 01 2014 : 19:45:41
Alternatively:

  SelBitmap := TIEBitmap.Create;
  ImageEnView1.CopySelectionToIEBitmap(SelBitmap);
  SelBitmap.Write(destFile);
  FreeAndNil(SelBitmap);

(Slightly less overhead)

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
skippix Posted - Jul 01 2014 : 17:04:04
I couldn't get it to work and wasn't able to readily find any examples for using XY values for cropping.

Instead, I opted for the easy way out: using another ImageEnView and modeling off the cropping done in the PhotoEn demo. Basically, assign the selection to the second component, then save.


  ieCropper := TImageEnView.Create(nil);
  ImageEnView1.AssignSelTo(ieCropper);
  ieCropper.IO.SaveToFile(destFile);
  FreeAndNil(ieCropper);


No fuss, no muss, and completely WYSIWYG :D
skippix Posted - Jun 29 2014 : 12:54:44
Thanks! I'll give it a shot and let you know how it works out, or if I need further assistance.
w2m Posted - Jun 28 2014 : 09:36:47
If ImageEnView.SelectionBase property is set to iesbClientArea you have to convert XY values. Without converting the simplest thing to do is to set ImageEnView.SelectionBase to iesbBitmap.

If SelectionBase is iesbClientArea (default) then all coordinates depend upon the actual zoom and window view/scrolling (i.e. pixels on screen). Otherwise, if SelectionBase is iesbBitmap, then all coordinates refer to bitmap pixels.

To convert XY values see:
- XBmp2Scr
- XScr2Bmp
- YBmp2Scr
- YScr2Bmp

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