![]() |
Überblendung zweier Bitmaps
Hallo!
Ich möchte zwei Bitmaps ineinander überblenden. Momentan realisiere ich das mit zwei Image-Komponenten in zwei unterschiedlichen Forms und ändere einfach den AlphaBlendValue des obenliegenden Forms. Das erscheint mir aber nicht unbedingt elegant. Gibt es eine andere und ebendso schnelle Möglichkeit? MfG GM |
Re: Überblendung zweier Bitmaps
du kannst die bilder in tbitmap lesen und pixel per pixel die Farbkanäle mischen.
kleines Beispiel:
Delphi-Quellcode:
P.S. : vergiss nicht dass es bloß ein beispiel ist. Anpassungen und SchnickSchnack wie skalieren und prozentuales Mischen habe ich nicht reingebaut. Das zweite Bild wird jedes mal OnClick um 50 % mit dem ersten gemischt.
procedure TForm1.Button2Click(Sender: TObject);
type TRGBArray = array[0..32767] of TRGBTriple; PRGBArray = ^TRGBArray; var x, y: Integer; RowA,RowB: PRGBArray; bmp1,bmp2 : tbitmap; begin bmp1 := image2.Picture.Bitmap; bmp2 := image3.Picture.Bitmap; try bmp1.PixelFormat := pf24bit; for y := 0 to bmp1.Height -1 do begin rowA := bmp1.ScanLine[y]; rowB := bmp2.ScanLine[y]; for x := 0 to bmp1.Width - 1 do begin rowA[x].rgbtRed := (rowA[x].rgbtRed + rowB[x].rgbtRed) div 2; rowA[x].rgbtGreen := (rowA[x].rgbtGreen + rowB[x].rgbtGreen) div 2; rowA[x].rgbtBlue := (rowA[x].rgbtBlue + rowB[x].rgbtBlue) div 2; end; end; finally image1.Picture.Bitmap := bmp1; end; |
Re: Überblendung zweier Bitmaps
Unter welchem Windows soll das ganze funktionieren? Bei XP geht folgendes (ab 2000 glaub ich)
Delphi-Quellcode:
procedure BlendBitmap(Dest: TBitmap; ABlendColor: TColor; ABlendIntensity: Byte = 127; GammaCorrection: Integer = 0);
var LSource: TBitmap; LBlendstruct: TBlendFunction; begin LBlendstruct.BlendOp := AC_SRC_OVER; LBlendstruct.BlendFlags := 0; LBlendstruct.SourceConstantAlpha := ABlendIntensity;// trunc(APercentBlendColor * 255 / 100); LBlendstruct.AlphaFormat := 0; //AC_SRC_ALPHA; LSource := TBitmap.Create; LSource.Width := 1; LSource.Height := 1; LSource.Canvas.Pixels[0,0] := ABlendColor; AlphaBlend(Dest.canvas.handle, 0, 0, Dest.width, Dest.height, LSource.canvas.Handle, 0, 0, 1, 1, LBlendstruct); if GammaCorrection <> 0 then begin LSource.Canvas.Pixels[0,0] := clWhite; LBlendstruct.SourceConstantAlpha := GammaCorrection; AlphaBlend(Dest.canvas.handle, 0, 0, Dest.width, Dest.height, LSource.canvas.Handle, 0, 0, 1, 1, LBlendstruct); end; LSource.Free; end; |
Re: Überblendung zweier Bitmaps
is das mit scanline nicht schneller ?!
//ups das is ja mit scanline *g* :duck: |
Re: Überblendung zweier Bitmaps
|
Re: Überblendung zweier Bitmaps
oder einfach mal ins msdn unter
![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz