mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 20:29:16 +02:00
gtk2: implement image flipping in StretchMaskBlt (part of issue #0013059)
git-svn-id: trunk@19215 -
This commit is contained in:
parent
624659d92d
commit
44fa480f4a
@ -1125,7 +1125,8 @@ end;
|
||||
function ScalePixmapAndMask(AScaleGC: PGDKGC; AScaleMethod: TGdkInterpType;
|
||||
ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, ASrcHeight: integer;
|
||||
ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap;
|
||||
ADstWidth, ADstHeight: Integer; out ADst, ADstMask: PGdkPixmap) : Boolean;
|
||||
ADstWidth, ADstHeight: Integer; FlipHorz, FlipVert: Boolean;
|
||||
out ADst, ADstMask: PGdkPixmap) : Boolean;
|
||||
|
||||
procedure Warn(const AText: String);
|
||||
begin
|
||||
@ -1149,6 +1150,40 @@ begin
|
||||
Warn('ScaleDst=nil');
|
||||
exit;
|
||||
end;
|
||||
|
||||
// flip if needed
|
||||
if FlipHorz then
|
||||
begin
|
||||
{$IFNDEF GTK1}
|
||||
ScaleSrc := ScaleDst;
|
||||
ScaleDst := gdk_pixbuf_flip(ScaleSrc, True);
|
||||
gdk_pixbuf_unref(ScaleSrc);
|
||||
if ScaleDst = nil
|
||||
then begin
|
||||
Warn('ScaleDst=nil');
|
||||
exit;
|
||||
end;
|
||||
{$ELSE}
|
||||
// TODO: implement flipping for gtk1
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
if FlipVert then
|
||||
begin
|
||||
{$IFNDEF GTK1}
|
||||
ScaleSrc := ScaleDst;
|
||||
ScaleDst := gdk_pixbuf_flip(ScaleSrc, False);
|
||||
gdk_pixbuf_unref(ScaleSrc);
|
||||
if ScaleDst = nil
|
||||
then begin
|
||||
Warn('ScaleDst=nil');
|
||||
exit;
|
||||
end;
|
||||
{$ELSE}
|
||||
// TODO: implement flipping for gtk1
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
// BeginGDKErrorTrap;
|
||||
|
||||
// Creating pixmap from scaled pixbuf
|
||||
|
@ -628,7 +628,8 @@ function CreatePixbufFromImageAndMask(ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth,
|
||||
function ScalePixmapAndMask(AScaleGC: PGDKGC; AScaleMethod: TGdkInterpType;
|
||||
ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, ASrcHeight: integer;
|
||||
ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap;
|
||||
ADstWidth, ADstHeight: Integer; out ADst, ADstMask: PGdkPixmap) : Boolean;
|
||||
ADstWidth, ADstHeight: Integer; FlipHorz, FlipVert: Boolean;
|
||||
out ADst, ADstMask: PGdkPixmap): Boolean;
|
||||
|
||||
// obsolete:
|
||||
function GetGdkImageBitsPerPixel(Image: PGdkImage): cardinal;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
@ -2346,6 +2346,7 @@ var
|
||||
TempPixmap: PGdkPixmap;
|
||||
TempMaskBitmap: PGdkBitmap;
|
||||
SizeChange, ROpIsSpecial: Boolean;
|
||||
FlipHorz, FlipVert: Boolean;
|
||||
|
||||
function ScaleAndROP(DestGC: PGDKGC;
|
||||
Src: PGDKDrawable; SrcPixmap: PGdkPixmap; SrcMaskBitmap: PGdkBitmap): Boolean;
|
||||
@ -2408,7 +2409,7 @@ var
|
||||
Result := ScalePixmapAndMask(GC, ScaleMethod,
|
||||
SrcPixmap, XSrc, YSrc, SrcWidth, SrcHeight,
|
||||
nil, SrcMaskBitmap,
|
||||
Width, Height, TempPixmap, TempMaskBitmap);
|
||||
Width, Height, FlipHorz, FlipVert, TempPixmap, TempMaskBitmap);
|
||||
if not Result
|
||||
then DebugLn('WARNING: ScaleAndROP ScalePixmap for pixmap failed');
|
||||
end
|
||||
@ -2672,10 +2673,25 @@ begin
|
||||
DebugLn('StretchCopyArea Start '+dbgs(Result));
|
||||
{$ENDIF}
|
||||
if not Result then Exit;
|
||||
if (Width = 0) or ( Height = 0) then exit;
|
||||
|
||||
FlipHorz := Width < 0;
|
||||
if FlipHorz then
|
||||
begin
|
||||
Width := -Width;
|
||||
X := X - Width;
|
||||
end;
|
||||
|
||||
FlipVert := Height < 0;
|
||||
if FlipVert then
|
||||
begin
|
||||
Height := -Height;
|
||||
Y := Y - Height;
|
||||
end;
|
||||
|
||||
if (Width = 0) or (Height = 0) then exit;
|
||||
if (SrcWidth = 0) or (SrcHeight = 0) then exit;
|
||||
|
||||
SizeChange := (Width <> SrcWidth) or (Height <> SrcHeight);
|
||||
SizeChange := (Width <> SrcWidth) or (Height <> SrcHeight) or FlipVert or FlipHorz;
|
||||
ROpIsSpecial := (ROp <> SRCCOPY);
|
||||
|
||||
SrcDCOrigin := SrcDevContext.Offset;
|
||||
|
@ -170,6 +170,9 @@ procedure gdk_pango_renderer_set_gc(gdk_renderer: PGdkPangoRenderer; gc: PGdkGC)
|
||||
procedure gdk_pango_renderer_set_override_color(gdk_renderer: PGdkPangoRenderer; part: TPangoRenderPart; color: PGdkColor); cdecl; external gdklib;
|
||||
// ------------------end of symbold to remove --------------------------
|
||||
|
||||
// gdk-pixbuf 2.6
|
||||
function gdk_pixbuf_flip(src: PGdkPixbuf; horizontal: gboolean): PGdkPixbuf; cdecl; external gdkpixbuflib;
|
||||
|
||||
{$ifdef GTK_2_8}
|
||||
// gdk 2.8
|
||||
procedure gdk_display_warp_pointer(display: PGdkDisplay; screen: PGdkScreen; x, y: gint); cdecl; external gdklib;
|
||||
|
Loading…
Reference in New Issue
Block a user