Hello,
I am using following code to set Crop area. But the crop area defined thus seem to keep on moving around randomly when we zoom the image using Scroll Wheel.
Here is the code that I am using:
var
CropForm: TfrmCropPhoto;
CropX, CropY, CropW, CropH : Integer;
CRect: TRect;
TotalLayers, CurrLayer: Integer;
begin
if ievMain.IsEmpty then Exit;
if ievMain.CurrentLayer.IsMask then Exit;
//If the layer above current layer is a Mask then get its geometry
TotalLayers := ievMain.LayersCount - 1;
CurrLayer := ievMain.LayersCurrent;
if ((CurrLayer + 1) <= (TotalLayers)) and (ievMain.LayersCurrent > 0) then
begin
CropX := 1400;
CropY := 230;
CropW := 878;
CropH := 800;
end
else
begin
MessageBeep(MB_ICONERROR);
ShowMessage('Selected Layer cannot be Cropped');
Exit;
end;
CRect := Rect(CropX,CropY,CropW,CropH);
CropForm := TfrmCropPhoto.Create(Application);
CropForm.ienViewCrop.Layers[0].Assign(ievMain.CurrentLayer);
CropForm.ienViewCrop.Proc.ClearAllUndo;
CropForm.ienViewCrop.Proc.ClearAllRedo;
CropForm.ienViewCrop.Proc.UndoLimit := 20;
CropForm.ienViewCrop.Fit();
CropForm.ienViewCrop.CropToolInteraction.DrawGuides := False;
CropForm.ienViewCrop.CropToolInteraction.AntialiasMode := ierBicubic;
CropForm.ienViewCrop.CropToolInteraction.GripSize := 12;
CropForm.ienViewCrop.CropToolInteraction.Mode := iectmRECTANGLE;
CropForm.ienViewCrop.Invalidate;
CropForm.ienViewCrop.MouseInteract := [miCropTool];
CropForm.Cursor := crIECrossSight;
//Set the crop size and Invalidate ImageEn for the crop size to take effect
CropForm.ienViewCrop.CropToolInteraction.SetBitmapPolygon(CRect);
CropForm.ienViewCrop.Invalidate();
CropForm.ienViewCrop.Fit();
if CropForm.ShowModal = mrOk then
begin
//Recreate the mask with new size and then bring in the picture
ievMain.CurrentLayer.Assign(CropForm.ienViewCrop.Layers[0]);
end; //if CropForm.ShowModal = mrOk then
CropForm.Free
How to solve this problem?
TIA
Yogi Yang