Skip to content

Commit

Permalink
Merge pull request #148 from bgrabitmap/dev-bgracontrols
Browse files Browse the repository at this point in the history
Dev bgracontrols
  • Loading branch information
lainz authored Jul 29, 2023
2 parents e41bd4b + 50b13bf commit 6ff22f8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bgracontrols.lpk
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
<UseAnsiStrings Value="False"/>
<CPPInline Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
Expand Down
18 changes: 12 additions & 6 deletions bgraimagemanipulation.pas
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,9 @@ function TCropArea.getResampledBitmap(OriginalRect :TRect): TBGRABitmap;

// Create bitmap to put image on final scale
Result := TBGRABitmap.Create(rScaledArea.Width, rScaledArea.Height);
Result.ResolutionUnit:=CropBitmap.ResolutionUnit;
Result.ResolutionX:=CropBitmap.ResolutionX;
Result.ResolutionY:=CropBitmap.ResolutionY;

// Resize the cropped image to final scale
ResampledBitmap := CropBitmap.Resample(rScaledArea.Width, rScaledArea.Height, rmFineResample);
Expand All @@ -851,11 +854,11 @@ function TCropArea.getBitmap: TBGRABitmap;
Result :=nil;
if not (fOwner.fImageBitmap.Empty) then
try
// Create a new bitmap for cropped region
Result := TBGRABitmap.Create(rArea.Width, rArea.Height);

// Get the cropped image on selected region in original scale
Result.Canvas.CopyRect(Rect(0,0, rArea.Width, rArea.Height), fOwner.fImageBitmap.Canvas, rArea);
Result :=fOwner.fImageBitmap.GetPart(rArea);
Result.ResolutionUnit:=fOwner.fImageBitmap.ResolutionUnit;
Result.ResolutionX:=fOwner.fImageBitmap.ResolutionX;
Result.ResolutionY:=fOwner.fImageBitmap.ResolutionY;
except
if (Result<>nil)
then FreeAndNil(Result);
Expand Down Expand Up @@ -935,10 +938,13 @@ procedure TCropAreaList.Load(const XMLConf: TXMLConfig);
try
loading :=True;

XMLConf.OpenKey(fOwner.Name+'.'+Self.Name);
newCount := XMLConf.GetValue('Count', -1);
if (newCount=-1)
then raise Exception.Create('XML Path not Found');

Clear;

XMLConf.OpenKey(fOwner.Name+'.'+Self.Name);
newCount := XMLConf.GetValue('Count', 0);
newSelected := XMLConf.GetValue('Selected', 0);
for i :=0 to newCount-1 do
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ procedure TFormBGRAImageManipulationDemo.edHeightChange(Sender: TObject; AByUser
if AByUser then
begin
CropArea :=TCropArea(cbBoxList.Items.Objects[cbBoxList.ItemIndex]);
CropArea.Height:=edHeight.Value;
if (CropArea<>nil)
then CropArea.Height:=edHeight.Value;
end;
end;

Expand All @@ -355,7 +356,8 @@ procedure TFormBGRAImageManipulationDemo.edLeftChange(Sender: TObject; AByUser:
if AByUser then
begin
CropArea :=TCropArea(cbBoxList.Items.Objects[cbBoxList.ItemIndex]);
CropArea.Left :=edLeft.Value;
if (CropArea<>nil)
then CropArea.Left :=edLeft.Value;
end;
end;

Expand All @@ -367,7 +369,8 @@ procedure TFormBGRAImageManipulationDemo.edTopChange(Sender: TObject; AByUser: b
if AByUser then
begin
CropArea :=TCropArea(cbBoxList.Items.Objects[cbBoxList.ItemIndex]);
CropArea.Top :=edTop.Value;
if (CropArea<>nil)
then CropArea.Top :=edTop.Value;
end;
end;

Expand All @@ -379,7 +382,8 @@ procedure TFormBGRAImageManipulationDemo.edWidthChange(Sender: TObject; AByUser:
if AByUser then
begin
CropArea :=TCropArea(cbBoxList.Items.Objects[cbBoxList.ItemIndex]);
CropArea.Width:=edWidth.Value;
if (CropArea<>nil)
then CropArea.Width:=edWidth.Value;
end;
end;

Expand Down

0 comments on commit 6ff22f8

Please sign in to comment.