mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 09:59:09 +02:00
IDE: Simplified anti-aliased stretch-drawing of "splash" and "about" forms.
git-svn-id: trunk@59715 -
This commit is contained in:
parent
d8dd2565cf
commit
4ae9277231
@ -307,20 +307,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAboutForm.LoadLogo;
|
procedure TAboutForm.LoadLogo;
|
||||||
var
|
|
||||||
pic: TPicture;
|
|
||||||
W, H: Integer;
|
|
||||||
begin
|
begin
|
||||||
pic := TPicture.Create;
|
LogoImage.Picture.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic);
|
||||||
try
|
AntiAliasedStretchBitmap(LogoImage.Picture.Bitmap, LogoImage.Width, LogoImage.Height);
|
||||||
pic.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic);
|
|
||||||
W := LogoImage.Width;
|
|
||||||
H := LogoImage.Height;
|
|
||||||
LogoImage.Picture.Bitmap.SetSize(W, H);
|
|
||||||
AntiAliasedStretchDrawBitmap(pic.Bitmap, LogoImage.Picture.Bitmap, W, H);
|
|
||||||
finally
|
|
||||||
pic.Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
object SplashForm: TSplashForm
|
object SplashForm: TSplashForm
|
||||||
Left = 561
|
Left = 561
|
||||||
Height = 341
|
Height = 300
|
||||||
Top = 370
|
Top = 370
|
||||||
Width = 429
|
Width = 429
|
||||||
HorzScrollBar.Page = 428
|
HorzScrollBar.Page = 428
|
||||||
VertScrollBar.Page = 340
|
VertScrollBar.Page = 340
|
||||||
BorderStyle = bsNone
|
BorderStyle = bsNone
|
||||||
Caption = 'Lazarus'
|
Caption = 'Lazarus'
|
||||||
ClientHeight = 341
|
ClientHeight = 300
|
||||||
ClientWidth = 429
|
ClientWidth = 429
|
||||||
FormStyle = fsSplash
|
FormStyle = fsSplash
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.9.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object Image: TImage
|
object Image: TImage
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 341
|
Height = 300
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 429
|
Width = 429
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
@ -124,18 +124,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSplashForm.LoadSplash;
|
procedure TSplashForm.LoadSplash;
|
||||||
var
|
|
||||||
pic: TPicture;
|
|
||||||
begin
|
begin
|
||||||
pic := TPicture.Create;
|
Image.Picture.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic);
|
||||||
try
|
Width := round(Height * Image.Picture.Width / Image.Picture.Height);
|
||||||
pic.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic);
|
AntiAliasedStretchBitmap(Image.Picture.Bitmap, Width, Height);
|
||||||
Width := round(Height * pic.Width / pic.Height);
|
|
||||||
Image.Picture.Bitmap.SetSize(Width, Height);
|
|
||||||
AntiAliasedStretchDrawBitmap(pic.Bitmap, Image.Picture.Bitmap, Width, Height);
|
|
||||||
finally
|
|
||||||
pic.Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSplashForm.Show;
|
procedure TSplashForm.Show;
|
||||||
|
@ -38,9 +38,10 @@ procedure DrawVerticalGradient(Canvas: TCanvas; ARect: TRect; TopColor, BottomCo
|
|||||||
{ Draw nice looking window with Title }
|
{ Draw nice looking window with Title }
|
||||||
procedure DrawGradientWindow(Canvas: TCanvas; WindowRect: TRect; TitleHeight: Integer; BaseColor: TColor);
|
procedure DrawGradientWindow(Canvas: TCanvas; WindowRect: TRect; TitleHeight: Integer; BaseColor: TColor);
|
||||||
|
|
||||||
{ Stretch-draw a bitmap in an anti-aliased way to another bitmap }
|
{ Stretch-draw a bitmap in an anti-aliased way }
|
||||||
procedure AntiAliasedStretchDrawBitmap(SourceBitmap, DestBitmap: TCustomBitmap;
|
procedure AntiAliasedStretchDrawBitmap(SourceBitmap, DestBitmap: TCustomBitmap;
|
||||||
DestWidth, DestHeight: integer);
|
DestWidth, DestHeight: integer);
|
||||||
|
procedure AntiAliasedStretchBitmap(ABitmap: TCustomBitmap; AWidth, AHeight: Integer);
|
||||||
|
|
||||||
{ Draw arrows }
|
{ Draw arrows }
|
||||||
type TScrollDirection=(sdLeft,sdRight,sdUp,sdDown);
|
type TScrollDirection=(sdLeft,sdRight,sdUp,sdDown);
|
||||||
@ -444,6 +445,34 @@ begin
|
|||||||
DrawVerticalGradient(Canvas, WindowRect, GetHighLightColor(BaseColor), GetShadowColor(BaseColor));
|
DrawVerticalGradient(Canvas, WindowRect, GetHighLightColor(BaseColor), GetShadowColor(BaseColor));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AntiAliasedStretchBitmap(ABitmap: TCustomBitmap;
|
||||||
|
AWidth, AHeight: Integer);
|
||||||
|
var
|
||||||
|
SrcImg, DestImg: TLazIntfImage;
|
||||||
|
DestCanvas: TLazCanvas;
|
||||||
|
begin
|
||||||
|
SrcImg := ABitmap.CreateIntfImage;
|
||||||
|
try
|
||||||
|
DestImg := TLazIntfImage.Create(0, 0);
|
||||||
|
DestImg.LoadFromBitmap(ABitmap.Handle, ABitmap.MaskHandle);
|
||||||
|
try
|
||||||
|
DestCanvas := TLazCanvas.Create(DestImg);
|
||||||
|
try
|
||||||
|
DestCanvas.Interpolation := TFPBaseInterpolation.Create;
|
||||||
|
DestCanvas.StretchDraw(0, 0, AWidth, AHeight, SrcImg);
|
||||||
|
ABitmap.LoadFromIntfImage(DestImg);
|
||||||
|
ABitmap.SetSize(AWidth, AHeight);
|
||||||
|
finally
|
||||||
|
DestCanvas.Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
DestImg.Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
SrcImg.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure AntiAliasedStretchDrawBitmap(SourceBitmap, DestBitmap: TCustomBitmap;
|
procedure AntiAliasedStretchDrawBitmap(SourceBitmap, DestBitmap: TCustomBitmap;
|
||||||
DestWidth, DestHeight: integer);
|
DestWidth, DestHeight: integer);
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user