Minor improvement to the custom drawn bitmap resizer

git-svn-id: trunk@36191 -
This commit is contained in:
sekelsenmat 2012-03-21 15:09:38 +00:00
parent 36928275f2
commit 72c633b780
2 changed files with 11 additions and 2 deletions

View File

@ -505,7 +505,7 @@ begin
TCDCHECKBOX_SQUARE_HALF_HEIGHT: Floor(GetMeasures(TCDCHECKBOX_SQUARE_HEIGHT)/2);
TCDCHECKBOX_SQUARE_HEIGHT: Result := DPIAdjustment(20);
//
TCDRADIOBUTTON_CIRCLE_HEIGHT: Result := DPIAdjustment(20);
TCDRADIOBUTTON_CIRCLE_HEIGHT: Result := DPIAdjustment(20); // Must be dividable by 4
//
{ TCDSCROLLBAR_BUTTON_WIDTH: Result := 17;
TCDSCROLLBAR_LEFT_SPACING: Result := 17;

View File

@ -545,10 +545,19 @@ end;
procedure TCDDrawer.ScaleRasterImage(ARasterImage: TRasterImage; ASourceDPI, ADestDPI: Word);
var
lNewWidth, lNewHeight: Int64;
lTmpBmp: TBitmap;
begin
lNewWidth := Round(ARasterImage.Width * ADestDPI / ASourceDPI);
lNewHeight := Round(ARasterImage.Height * ADestDPI / ASourceDPI);
ARasterImage.Canvas.StretchDraw(Bounds(0, 0, lNewWidth, lNewHeight), ARasterImage);
lTmpBmp := TBitmap.Create;
try
lTmpBmp.Width := ARasterImage.Width;
lTmpBmp.Height := ARasterImage.Height;
lTmpBmp.Canvas.Draw(0, 0, ARasterImage);
ARasterImage.Canvas.StretchDraw(Bounds(0, 0, lNewWidth, lNewHeight), lTmpBmp);
finally
lTmpBmp.Free;
end;
ARasterImage.Width := lNewWidth;
ARasterImage.Height := lNewHeight;
end;