Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Graphics32 + Masks (https://www.delphipraxis.net/199531-graphics32-masks.html)

Wishmaster 30. Jan 2019 07:40

Graphics32 + Masks
 
Liste der Anhänge anzeigen (Anzahl: 1)
in meine komponenten versuche ich abgerundete ecken zu integrieren, was auch grundsätzlich funktioniert.
allerdings wenn ich versuche ein Bild /Texture drüber zu legen bekomme ich diese widerlichen ecken nicht wech.


die komponente ist eine TCustomControl und ich habe so ne art fake Transparenz implementiert in dem ich den parent hintergrund kopiere und als ersten layer zeichne.
und dann die eigentlichen elemente drüber zeichne (Farben, texture, Text, ...) so wenn ich abgerundete ecken habe sieht das so aus als ob die kommponnente Transparent ist.



Delphi-Quellcode:
     


procedure AddPolygon_FloatPoint(const Pts: TArrayOfFloatPoint; // << Test function
 var Polys : TArrayOfArrayOfFloatPoint; Idx : Integer = 0);
begin
 with TClipper.Create do
  try
     Add(Polys, ptSubject);
     Add(Pts, ptClip);
    case idx of
      0 : Execute(ctUnion, Polys, pftNegative);
      1 : Execute(ctIntersection, Polys, pftNonZero);
      2 : Execute(ctUnion, Polys, pftNonZero);
      3 : Execute(ctDifference, Polys, pftNonZero);
     else
      Execute(ctXor, Polys, pftNonZero);
    end;
  finally
   Free;
  end;
end;


procedure TjbAdvPanel.DrawPannel(Dst : TBitmap32; R: TRect);
var
  Buffer : TBitmap32;

  BkColor : TColor;

  // test
  FRect : TFloatRect;
  Mask : TBitmap32;
  Poly : TArrayOfArrayOfFloatPoint;
  FOutline, FSB : TArrayOfFloatPoint;

  FP : TArrayOfFixedPoint;
begin
  FRect:= FloatRect(R);


 with FLookAndFeel do
  begin
    Buffer:= TBitmap32.Create();
    Buffer.SetSize(R.Width, R.Height);
    Buffer.ResetAlpha;
    Buffer.MasterAlpha:= FAlphaBlendValue;
    Buffer.DrawMode:= dmBlend;

   if Transparent then
    ApplyTransparentColor(Buffer, clBlack32);


    Mask := TBitmap32.Create;

   if not FTransparent then
    begin
     with FLookAndFeel do
      begin
       if (MaskType = bcAuto) then
        begin
         if Parent.Enabled then
          BkColor:= TWinControlAccess(Parent).Color;
        end else
       if MaskType = bcUser then
        begin
          BkColor:= MaskColor;
        end;
      end;
    end;

    case BackgroundStyle of
      bsGradient:
       begin


        Buffer.DrawTo(Dst, 0, 0);
       end;
      bsImage:
       begin

        if FFrame.FrameStyle = fsFlatRounded then          // << Problem
         begin
           Image.PaintTo(Buffer, R);  //  << Get Image


           SetLength(Poly, 0);
           FOutline:= BuildRectangle(FRect);
           AddPolygon_FloatPoint(FOutline, Poly, 2);
           PolyPolygonFS(Mask, Poly, Color32(clBlack), pfWinding);


           FOutline:= BuildRoundRect(FFrame.RoundRadius, FRect);
           AddPolygon_FloatPoint(FOutline, Poly, 3);
           PolyPolygonFS(Buffer, Poly, Color32(clBtnFace), pfWinding);


           Buffer.DrawTo(Dst, 0, 0);

      bsTraditional:
       begin

        if FFrame.FrameStyle = fsFlatRounded then
         begin
          if not Transparent then
           Buffer.FillRectS(0, 0, R.Width, R.Height, Color32(BkColor));
           FOutline:= BuildRoundRect(FFrame.RoundRadius + 1, FRect);
           PolygonFS(Buffer, FOutline, Color32(Color))
         end
        else
         begin
           Buffer.FillRectS(0, 0, R.Width, R.Height, Color32(Color));
         end;

         Buffer.DrawTo(Dst, 0, 0);
       end;
    end;


    Mask.Free;
    Buffer.Free
  end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz