gtk: fix copying a rect from drawable to bitmap (issue #0012131)

git-svn-id: trunk@20024 -
This commit is contained in:
paul 2009-05-18 07:11:28 +00:00
parent 37d924f53b
commit 447f5d8a3c
3 changed files with 19 additions and 13 deletions

View File

@ -1053,7 +1053,7 @@ begin
EndGDKErrorTrap; EndGDKErrorTrap;
end; end;
function CreatePixbufFromImageAndMask(ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, function CreatePixbufFromImageAndMask(ASrc: PGdkDrawable; ASrcX, ASrcY, ASrcWidth,
ASrcHeight: integer; ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap): PGdkPixbuf; ASrcHeight: integer; ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap): PGdkPixbuf;
procedure Warn(const AText: String); procedure Warn(const AText: String);

View File

@ -619,7 +619,7 @@ procedure MergeClipping(DestinationDC: TGtkDeviceContext; DestinationGC: PGDKGC;
X,Y,Width,Height: integer; ClipMergeMask: PGdkBitmap; X,Y,Width,Height: integer; ClipMergeMask: PGdkBitmap;
ClipMergeMaskX, ClipMergeMaskY: integer; ClipMergeMaskX, ClipMergeMaskY: integer;
var NewClipMask: PGdkBitmap); var NewClipMask: PGdkBitmap);
function CreatePixbufFromImageAndMask(ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, function CreatePixbufFromImageAndMask(ASrc: PGdkDrawable; ASrcX, ASrcY, ASrcWidth,
ASrcHeight: integer; ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap): PGdkPixbuf; ASrcHeight: integer; ASrcColorMap: PGdkColormap; ASrcMask: PGdkBitmap): PGdkPixbuf;
function ScalePixmapAndMask(AScaleGC: PGDKGC; AScaleMethod: TGdkInterpType; function ScalePixmapAndMask(AScaleGC: PGDKGC; AScaleMethod: TGdkInterpType;
ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, ASrcHeight: integer; ASrc: PGdkPixmap; ASrcX, ASrcY, ASrcWidth, ASrcHeight: integer;

View File

@ -2493,7 +2493,7 @@ var
FlipHorz, FlipVert: Boolean; FlipHorz, FlipVert: Boolean;
function ScaleAndROP(DestGC: PGDKGC; function ScaleAndROP(DestGC: PGDKGC;
Src: PGDKDrawable; SrcPixmap: PGdkPixmap; SrcMaskBitmap: PGdkBitmap): Boolean; Src: PGDKDrawable; SrcPixmap: PGdkDrawable; SrcMaskBitmap: PGdkBitmap): Boolean;
var var
Depth: Integer; Depth: Integer;
ScaleMethod: TGdkInterpType; ScaleMethod: TGdkInterpType;
@ -2616,7 +2616,7 @@ var
function SrcDevBitmapToDrawable: Boolean; function SrcDevBitmapToDrawable: Boolean;
var var
SrcPixmap: PGdkPixmap; SrcDrawable: PGdkDrawable;
MskBitmap: PGdkBitmap; MskBitmap: PGdkBitmap;
ClipMask: PGdkBitmap; ClipMask: PGdkBitmap;
SrcGDIBitmap: PGdiObject; SrcGDIBitmap: PGdiObject;
@ -2629,12 +2629,18 @@ var
SrcGDIBitmap := SrcDevContext.CurrentBitmap; SrcGDIBitmap := SrcDevContext.CurrentBitmap;
if SrcGDIBitmap = nil if SrcGDIBitmap = nil
then begin then begin
DebugLn('SrcDevBitmapToDrawable NOTE: SrcDevContext.CurrentBitmap=nil'); SrcDrawable := SrcDevContext.Drawable;
MskBitmap := nil;
if SrcDrawable = nil then
begin
DebugLn('SrcDevBitmapToDrawable NOTE: SrcDevContext.CurrentBitmap=nil, SrcDevContext.Drawable = nil');
exit; exit;
end; end;
end
SrcPixmap := SrcGDIBitmap^.GDIPixmapObject.Image; else begin
SrcDrawable := SrcGDIBitmap^.GDIPixmapObject.Image;
MskBitmap := CreateGdkMaskBitmap(HBITMAP(PtrUInt(SrcGDIBitmap)), Mask); MskBitmap := CreateGdkMaskBitmap(HBITMAP(PtrUInt(SrcGDIBitmap)), Mask);
end;
{$IFDEF VerboseStretchCopyArea} {$IFDEF VerboseStretchCopyArea}
DebugLn('SrcDevBitmapToDrawable SrcPixmap=[',GetWindowDebugReport(SrcPixmap),']', DebugLn('SrcDevBitmapToDrawable SrcPixmap=[',GetWindowDebugReport(SrcPixmap),']',
@ -2648,14 +2654,14 @@ var
DebugLn('SrcDevBitmapToDrawable Simple copy'); DebugLn('SrcDevBitmapToDrawable Simple copy');
{$ENDIF} {$ENDIF}
gdk_window_copy_area(DstDevContext.Drawable, DstDevContext.GC, X, Y, gdk_window_copy_area(DstDevContext.Drawable, DstDevContext.GC, X, Y,
SrcPixmap, XSrc, YSrc, Width, Height); SrcDrawable, XSrc, YSrc, Width, Height);
Exit; Exit;
end; end;
// perform raster operation and scaling into Scale and fGC // perform raster operation and scaling into Scale and fGC
DstDevContext.SelectedColors := dcscCustom; DstDevContext.SelectedColors := dcscCustom;
if not ScaleAndROP(DstDevContext.GC, SrcDevContext.Drawable, SrcPixmap, MskBitmap) if not ScaleAndROP(DstDevContext.GC, SrcDevContext.Drawable, SrcDrawable, MskBitmap)
then begin then begin
DebugLn('WARNING: SrcDevBitmapToDrawable: ScaleAndROP failed'); DebugLn('WARNING: SrcDevBitmapToDrawable: ScaleAndROP failed');
Exit; Exit;
@ -2666,7 +2672,7 @@ var
{$ENDIF} {$ENDIF}
if TempPixmap <> nil if TempPixmap <> nil
then begin then begin
SrcPixmap := TempPixmap; SrcDrawable := TempPixmap;
XSrc := 0; XSrc := 0;
YSrc := 0; YSrc := 0;
SrcWidth := Width; SrcWidth := Width;
@ -2700,7 +2706,7 @@ var
// draw image // draw image
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF} {$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
gdk_window_copy_area(DstDevContext.Drawable, DstDevContext.GC, X, Y, gdk_window_copy_area(DstDevContext.Drawable, DstDevContext.GC, X, Y,
SrcPixmap, XSrc, YSrc, SrcWidth, SrcHeight); SrcDrawable, XSrc, YSrc, SrcWidth, SrcHeight);
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF} {$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
// unset clipping mask for transparency // unset clipping mask for transparency