From 4ae9277231d235234f4bfe361cc0b3bfd48ad23c Mon Sep 17 00:00:00 2001 From: wp Date: Sun, 2 Dec 2018 17:34:07 +0000 Subject: [PATCH] IDE: Simplified anti-aliased stretch-drawing of "splash" and "about" forms. git-svn-id: trunk@59715 - --- ide/aboutfrm.pas | 15 ++------------- ide/splash.lfm | 8 ++++---- ide/splash.pp | 14 +++----------- lcl/graphutil.pp | 31 ++++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ide/aboutfrm.pas b/ide/aboutfrm.pas index e2a6e53d81..7364b36b1e 100644 --- a/ide/aboutfrm.pas +++ b/ide/aboutfrm.pas @@ -307,20 +307,9 @@ begin end; procedure TAboutForm.LoadLogo; -var - pic: TPicture; - W, H: Integer; begin - pic := TPicture.Create; - try - 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; + LogoImage.Picture.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic); + AntiAliasedStretchBitmap(LogoImage.Picture.Bitmap, LogoImage.Width, LogoImage.Height); end; diff --git a/ide/splash.lfm b/ide/splash.lfm index d14da491d6..34882f7593 100644 --- a/ide/splash.lfm +++ b/ide/splash.lfm @@ -1,20 +1,20 @@ object SplashForm: TSplashForm Left = 561 - Height = 341 + Height = 300 Top = 370 Width = 429 HorzScrollBar.Page = 428 VertScrollBar.Page = 340 BorderStyle = bsNone Caption = 'Lazarus' - ClientHeight = 341 + ClientHeight = 300 ClientWidth = 429 FormStyle = fsSplash Position = poScreenCenter - LCLVersion = '1.9.0.0' + LCLVersion = '2.1.0.0' object Image: TImage Left = 0 - Height = 341 + Height = 300 Top = 0 Width = 429 Align = alClient diff --git a/ide/splash.pp b/ide/splash.pp index 28380cf6dc..534bd23ea1 100644 --- a/ide/splash.pp +++ b/ide/splash.pp @@ -124,18 +124,10 @@ begin end; procedure TSplashForm.LoadSplash; -var - pic: TPicture; begin - pic := TPicture.Create; - try - pic.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic); - 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; + Image.Picture.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic); + Width := round(Height * Image.Picture.Width / Image.Picture.Height); + AntiAliasedStretchBitmap(Image.Picture.Bitmap, Width, Height); end; procedure TSplashForm.Show; diff --git a/lcl/graphutil.pp b/lcl/graphutil.pp index ac46a69739..e41fba2821 100644 --- a/lcl/graphutil.pp +++ b/lcl/graphutil.pp @@ -38,9 +38,10 @@ procedure DrawVerticalGradient(Canvas: TCanvas; ARect: TRect; TopColor, BottomCo { Draw nice looking window with Title } 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; DestWidth, DestHeight: integer); +procedure AntiAliasedStretchBitmap(ABitmap: TCustomBitmap; AWidth, AHeight: Integer); { Draw arrows } type TScrollDirection=(sdLeft,sdRight,sdUp,sdDown); @@ -444,6 +445,34 @@ begin DrawVerticalGradient(Canvas, WindowRect, GetHighLightColor(BaseColor), GetShadowColor(BaseColor)); 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; DestWidth, DestHeight: integer); var