mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 00:02:50 +02:00
LCL: Support for TImage.AntialiasingMode (stretching). Implement Win32 and GTK2. Issue #22205, patch from Chronos
git-svn-id: trunk@39894 -
This commit is contained in:
parent
809f049924
commit
7548ba8e96
@ -464,6 +464,7 @@ type
|
||||
|
||||
TCustomImage = class(TGraphicControl)
|
||||
private
|
||||
FAntialiasingMode: TAntialiasingMode;
|
||||
FOnPictureChanged: TNotifyEvent;
|
||||
FPicture: TPicture;
|
||||
FCenter: Boolean;
|
||||
@ -472,6 +473,7 @@ type
|
||||
FStretch: Boolean;
|
||||
FUseAncestorCanvas: boolean;
|
||||
function GetCanvas: TCanvas;
|
||||
procedure SetAntialiasingMode(AValue: TAntialiasingMode);
|
||||
procedure SetPicture(const AValue: TPicture);
|
||||
procedure SetCenter(const AValue : Boolean);
|
||||
procedure SetProportional(const AValue: Boolean);
|
||||
@ -491,6 +493,7 @@ type
|
||||
property Canvas: TCanvas read GetCanvas;
|
||||
function DestRect: TRect; virtual;
|
||||
public
|
||||
property AntialiasingMode: TAntialiasingMode read FAntialiasingMode write SetAntialiasingMode default amDontCare;
|
||||
property Align;
|
||||
property AutoSize;
|
||||
property Center: Boolean read FCenter write SetCenter default False;
|
||||
@ -512,6 +515,7 @@ type
|
||||
|
||||
TImage = class(TCustomImage)
|
||||
published
|
||||
property AntialiasingMode;
|
||||
property Align;
|
||||
property Anchors;
|
||||
property AutoSize;
|
||||
|
@ -65,6 +65,13 @@ begin
|
||||
Result := inherited Canvas;
|
||||
end;
|
||||
|
||||
procedure TCustomImage.SetAntialiasingMode(AValue: TAntialiasingMode);
|
||||
begin
|
||||
if FAntialiasingMode = AValue then Exit;
|
||||
FAntialiasingMode := AValue;
|
||||
PictureChanged(Self);
|
||||
end;
|
||||
|
||||
procedure TCustomImage.SetPicture(const AValue: TPicture);
|
||||
begin
|
||||
if FPicture=AValue then exit;
|
||||
@ -206,6 +213,7 @@ begin
|
||||
|
||||
C := inherited Canvas;
|
||||
R := DestRect;
|
||||
C.AntialiasingMode := FAntialiasingMode;
|
||||
C.StretchDraw(R, Picture.Graphic);
|
||||
|
||||
FUseAncestorCanvas := True;
|
||||
|
@ -345,6 +345,7 @@ type
|
||||
DCTextMetric: TDevContextTextMetric; // only valid if dcfTextMetricsValid set
|
||||
PaintRectangle: TRect;// set during paint, BeginPaint/EndPaint
|
||||
SavedContext: TGtkDeviceContext; // linked list of saved DCs
|
||||
Antialiasing: Boolean;
|
||||
|
||||
constructor Create; virtual;
|
||||
procedure CreateGDIObject(AGDIType: TGDIType);
|
||||
|
@ -251,6 +251,7 @@ type
|
||||
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);
|
||||
{$ENDIF}
|
||||
|
||||
procedure DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean); override;
|
||||
function DCGetPixel(CanvasHandle: HDC; X, Y: integer): TGraphicsColor; override;
|
||||
procedure DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor); override;
|
||||
procedure DCRedraw(CanvasHandle: HDC); override;
|
||||
|
@ -3720,7 +3720,10 @@ var
|
||||
else
|
||||
if ShrinkWidth or ShrinkHeight
|
||||
then ScaleMethod := GDK_INTERP_BILINEAR//GDK_INTERP_HYPER
|
||||
else ScaleMethod := GDK_INTERP_BILINEAR;
|
||||
else begin
|
||||
if DstDevContext.Antialiasing then ScaleMethod := GDK_INTERP_BILINEAR
|
||||
else ScaleMethod := GDK_INTERP_NEAREST;
|
||||
end;
|
||||
|
||||
// Scale the src part to a temporary pixmap with the size of the
|
||||
// destination rectangle
|
||||
@ -5224,6 +5227,21 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TGtk2WidgetSet.DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean
|
||||
);
|
||||
var
|
||||
DC: TGtk2DeviceContext;
|
||||
begin
|
||||
if IsValidDC(CanvasHandle) then
|
||||
begin
|
||||
//if CanvasHandle = 1 then
|
||||
//DC := Gtk2DefaultContext
|
||||
//else
|
||||
DC := TGtk2DeviceContext(CanvasHandle);
|
||||
DC.Antialiasing := AEnabled;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: NewDC
|
||||
|
@ -161,6 +161,7 @@ type
|
||||
{ Destructor of the class }
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean); override;
|
||||
function LCLPlatform: TLCLPlatform; override;
|
||||
function GetLCLCapability(ACapability: TLCLCapability): PtrUInt; override;
|
||||
|
||||
|
@ -105,6 +105,12 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TWin32WidgetSet.DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean);
|
||||
begin
|
||||
if AEnabled then SetStretchBltMode(CanvasHandle, HALFTONE)
|
||||
else SetStretchBltMode(CanvasHandle, COLORONCOLOR);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TWin32WidgetSet.AppInit
|
||||
Params: None
|
||||
|
@ -3567,7 +3567,6 @@ begin
|
||||
Blend.AlphaFormat := AC_SRC_ALPHA;
|
||||
end;
|
||||
|
||||
Windows.SetStretchBltMode(DestDC, STRETCH_HALFTONE);
|
||||
Windows.SetBrushOrgEx(DestDC, 0, 0, nil);
|
||||
if Mask = 0 then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user