AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Graphics32 + Masks

Ein Thema von Wishmaster · begonnen am 30. Jan 2019
Antwort Antwort
Wishmaster

Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
 
Delphi XE2 Architect
 
#1

Graphics32 + Masks

  Alt 30. Jan 2019, 07:40
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;
Miniaturansicht angehängter Grafiken
demo.jpg  
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:10 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