mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 23:49:36 +02:00
fixed win32 painting and started creating bitmaps from rawimages
git-svn-id: trunk@4355 -
This commit is contained in:
parent
418b60a004
commit
fb7551ba76
@ -149,11 +149,18 @@ begin
|
||||
SendMsgToInterface:=@IntSendMessage3;
|
||||
end;
|
||||
|
||||
function TInterfaceBase.CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP;
|
||||
function TInterfaceBase.CreateBitmap(Width, Height: Integer;
|
||||
Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TInterfaceBase.CreateBitmapFromRawImage(const RawImage: TRawImage;
|
||||
var Bitmap, MaskBitmap: HBitmap): boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TInterfaceBase.CreateDIBitmap(DC: HDC;
|
||||
var InfoHeader: TBitmapInfoHeader;
|
||||
dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo;
|
||||
@ -1768,6 +1775,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.94 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.93 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -126,6 +126,12 @@ begin
|
||||
BitmapBits);
|
||||
end;
|
||||
|
||||
function CreateBitmapFromRawImage(const RawImage: TRawImage;
|
||||
var Bitmap, MaskBitmap: HBitmap): boolean;
|
||||
begin
|
||||
Result := InterfaceObject.CreateBitmapFromRawImage(RawImage,Bitmap,MaskBitmap);
|
||||
end;
|
||||
|
||||
function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader;
|
||||
dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo;
|
||||
wUsage: UINT): HBITMAP;
|
||||
@ -1623,6 +1629,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.88 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.87 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -61,6 +61,7 @@ function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; {$I
|
||||
Function CombineRgn(Dest, Src1, Src2 : HRGN; fnCombineMode : Longint) : Longint; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateCaret(Handle: HWND; Bitmap: hBitmap; width, Height: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
@ -386,6 +387,9 @@ procedure RaiseLastOSError;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.81 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.80 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -2243,7 +2243,7 @@ begin
|
||||
begin
|
||||
if not (csCustomPaint in ControlState) and (ControlCount = 0) then
|
||||
begin
|
||||
// no inherited method to call...
|
||||
DefaultHandler(Msg);
|
||||
end
|
||||
else
|
||||
PaintHandler(Msg);
|
||||
@ -2885,6 +2885,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.150 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.149 2003/06/30 16:39:40 mattias
|
||||
clean up
|
||||
|
||||
|
@ -155,6 +155,8 @@ type
|
||||
BitSize : Longint; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT; DIB : Boolean): Integer;virtual;
|
||||
function GetWindowRawImageDescription(GDKWindow: PGdkWindow;
|
||||
Desc: PRawImageDescription): boolean;
|
||||
function GetRawImageFromGdkWindow(GDKWindow: PGdkWindow;
|
||||
const SrcRect: TRect; var NewRawImage: TRawImage): boolean;
|
||||
|
||||
// RC file
|
||||
procedure SetRCFilename(const AValue: string);virtual;
|
||||
@ -347,6 +349,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.134 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.133 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -1905,7 +1905,7 @@ begin
|
||||
Desc^.BluePrec:=Visual^.blue_prec;
|
||||
Desc^.BlueShift:=Visual^.blue_shift;
|
||||
Desc^.AlphaMask:=true;
|
||||
Desc^.AlphaPrec:=1;
|
||||
Desc^.AlphaPrec:=0;
|
||||
Desc^.AlphaShift:=0;
|
||||
// AlphaBitsPerPixel and AlphaLineEnd
|
||||
Desc^.AlphaBitsPerPixel:=Desc^.AlphaPrec;
|
||||
@ -1941,6 +1941,97 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TgtkObject.GetRawImageFromGdkWindow(GDKWindow: PGdkWindow;
|
||||
const SrcRect: TRect; var NewRawImage: TRawImage): boolean;
|
||||
var
|
||||
ARect: TRect;
|
||||
MaxRect: TRect;
|
||||
SourceRect: TRect;
|
||||
AnImage: PGdkImage;
|
||||
{y: Integer;
|
||||
x: Integer;
|
||||
AColor: guint;
|
||||
i: Integer;}
|
||||
begin
|
||||
Result:=false;
|
||||
FillChar(NewRawImage,SizeOf(NewRawImage),0);
|
||||
if GdkWindow=nil then
|
||||
RaiseGDBException('TgtkObject.GetRawImageFromGdkWindow');
|
||||
|
||||
// get raw image description
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow A GdkWindow=',HexStr(Cardinal(GdkWindow),8));
|
||||
if not GetWindowRawImageDescription(GdkWindow,@NewRawImage.Description) then
|
||||
exit;
|
||||
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow B ');
|
||||
// get intersection
|
||||
ARect:=SrcRect;
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow D ARect=',ARect.Left,',',ARect.Top,',',ARect.Right,',',ARect.Bottom,' DevW=',NewRawImage.Description.Width,' DevH=',NewRawImage.Description.Height);
|
||||
MaxRect:=Rect(0,0,NewRawImage.Description.Width,
|
||||
NewRawImage.Description.Height);
|
||||
SourceRect:=ARect;
|
||||
IntersectRect(SourceRect,ARect,MaxRect);
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow E SourceRect=',SourceRect.Left,',',SourceRect.Top,',',SourceRect.Right,',',SourceRect.Bottom);
|
||||
NewRawImage.Description.Width:=SourceRect.Right-SourceRect.Left;
|
||||
NewRawImage.Description.Height:=SourceRect.Bottom-SourceRect.Top;
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow F ',SourceRect.Left,',',SourceRect.Top,',',SourceRect.Right,',',SourceRect.Bottom,' GDKWindow=',HexStr(Cardinal(GDkWindow),8));
|
||||
if (NewRawImage.Description.Width=0) or (NewRawImage.Description.Height=0)
|
||||
then exit;
|
||||
|
||||
// get gdk_image
|
||||
AnImage:=gdk_image_get(GDKWindow,SourceRect.Left,SourceRect.Top,
|
||||
NewRawImage.Description.Width,
|
||||
NewRawImage.Description.Height);
|
||||
if AnImage=nil then begin
|
||||
writeln('WARNING: TgtkObject.GetRawImageFromGdkWindow gdk_image_get failed');
|
||||
exit;
|
||||
end;
|
||||
try
|
||||
// consistency checks
|
||||
if NewRawImage.Description.Depth<>AnImage^.Depth then
|
||||
RaiseGDBException('NewRawImage.Description.Depth<>AnImage^.Depth');
|
||||
if NewRawImage.Description.BitsPerPixel<>AnImage^.bpp then
|
||||
RaiseGDBException('NewRawImage.Description.BitsPerPixel<>AnImage^.bpp');
|
||||
|
||||
NewRawImage.DataSize:=(NewRawImage.Description.BitsPerPixel shr 3)
|
||||
*AnImage^.Width*AnImage^.Height;
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow G Width=',AnImage^.Width,' Height=',AnImage^.Height,' BitsPerPixel=',NewRawImage.Description.BitsPerPixel,' bpl=',AnImage^.bpl);
|
||||
if NewRawImage.DataSize<>AnImage^.bpl*AnImage^.Height then
|
||||
RaiseGDBException('NewRawImage.DataSize<>AnImage^.bpl*AnImage^.Height');
|
||||
|
||||
// copy data
|
||||
NewRawImage.Description.Width:=AnImage^.Width;
|
||||
NewRawImage.Description.Height:=AnImage^.Height;
|
||||
|
||||
{NewRawImage.Description.BitsPerPixel:=SizeOf(GUInt)*8;
|
||||
NewRawImage.DataSize:=AnImage^.Width*AnImage^.Height*SizeOf(GUInt);
|
||||
ReAllocMem(NewRawImage.Data,NewRawImage.DataSize);
|
||||
i:=0;
|
||||
for y:=0 to AnImage^.Height-1 do begin
|
||||
for x:=0 to AnImage^.Width-1 do begin
|
||||
AColor:=gdk_image_get_pixel(AnImage,x,y);
|
||||
pGuint(NewRawImage.Data)[i]:=AColor;
|
||||
if (y=5) then write(' ',HexStr(Cardinal(AColor),8),'@',HexStr(Cardinal(@pGuint(NewRawImage.Data)[i]),8));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
writeln('');}
|
||||
ReAllocMem(NewRawImage.Data,NewRawImage.DataSize);
|
||||
if NewRawImage.DataSize>0 then
|
||||
System.Move(AnImage^.Mem^,NewRawImage.Data^,NewRawImage.DataSize);
|
||||
|
||||
writeln('TgtkObject.GetRawImageFromGdkWindow H ',
|
||||
' Width=',NewRawImage.Description.Width,
|
||||
' Height=',NewRawImage.Description.Height,
|
||||
' Depth=',NewRawImage.Description.Depth,
|
||||
' DataSize=',NewRawImage.DataSize);
|
||||
finally
|
||||
gdk_image_destroy(AnImage);
|
||||
end;
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure TGtkObject.ListViewChangeItem(TheListView: TObject; Index: integer);
|
||||
var
|
||||
ListView: TListView;
|
||||
@ -7791,6 +7882,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.388 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.387 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -827,6 +827,69 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TgtkObject.CreateBitmapFromRawImage(const RawImage: TRawImage;
|
||||
var Bitmap, MaskBitmap: HBitmap): Boolean;
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
function TgtkObject.CreateBitmapFromRawImage(const RawImage: TRawImage;
|
||||
var Bitmap, MaskBitmap: HBitmap): boolean;
|
||||
var
|
||||
GdiObject: PGDIObject;
|
||||
DefGDkWindow: PGdkWindow;
|
||||
fg, bg: TGdkColor;
|
||||
begin
|
||||
Result:=false;
|
||||
Bitmap:=0;
|
||||
MaskBitmap:=0;
|
||||
|
||||
writeln('TgtkObject.CreateBitmapFromRawImage A ',
|
||||
' Depth=',RawImage.Description.Depth,
|
||||
' Width=',RawImage.Description.Width,
|
||||
' Height=',RawImage.Description.Height,
|
||||
' Data=',HexStr(Cardinal(RawImage.Data),8),
|
||||
' DataSize=',RawImage.DataSize,
|
||||
' Mask=',HexStr(Cardinal(RawImage.Mask),8),
|
||||
' MaskSize=',RawImage.MaskSize,
|
||||
' Palette=',HexStr(Cardinal(RawImage.Palette),8),
|
||||
' PaletteSize=',RawImage.PaletteSize,
|
||||
'');
|
||||
|
||||
// ToDo: check description
|
||||
|
||||
DefGdkWindow := nil;
|
||||
gdk_color_white(gdk_colormap_get_system, @fg);
|
||||
gdk_color_black(gdk_colormap_get_system, @bg);
|
||||
|
||||
GdiObject := NewGDIObject(gdiBitmap);
|
||||
GdiObject^.GDIBitmapType := gbPixmap;
|
||||
|
||||
if RawImage.Data<>nil then begin
|
||||
GdiObject^.GDIPixmapObject :=
|
||||
gdk_pixmap_create_from_data(DefGdkWindow,PGChar(RawImage.Data),
|
||||
RawImage.Description.Width, RawImage.Description.Height,
|
||||
RawImage.Description.Depth, @fg,@bg);
|
||||
end else
|
||||
GdiObject^.GDIBitmapObject :=
|
||||
gdk_pixmap_new(DefGdkWindow,
|
||||
RawImage.Description.Width, RawImage.Description.Height,
|
||||
RawImage.Description.Depth);
|
||||
GdiObject^.Visual := gdk_window_get_visual(GdiObject^.GDIBitmapObject);
|
||||
Bitmap:=HBITMAP(GdiObject);
|
||||
|
||||
If (RawImage.Mask<>nil) then begin
|
||||
GdiObject := NewGDIObject(gdiBitmap);
|
||||
GdiObject^.GDIBitmapType := gbBitmap;
|
||||
GdiObject^.GDIBitmapObject :=
|
||||
gdk_bitmap_create_from_data(DefGdkWindow,PGChar(RawImage.Mask),
|
||||
RawImage.Description.Width, RawImage.Description.Height);
|
||||
GdiObject^.Visual := gdk_window_get_visual(GdiObject^.GDIPixmapObject);
|
||||
MaskBitmap:=HBITMAP(GdiObject);
|
||||
end;
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: CreateBrushIndirect
|
||||
Params: none
|
||||
@ -4085,114 +4148,21 @@ function TgtkObject.GetRawImageFromDevice(SrcDC: HDC; const SrcRect: TRect;
|
||||
var
|
||||
DCOrigin: TPoint;
|
||||
ARect: TRect;
|
||||
MaxRect: TRect;
|
||||
SourceRect: TRect;
|
||||
AnImage: PGdkImage;
|
||||
GDKWindow: PGdkWindow;
|
||||
{y: Integer;
|
||||
x: Integer;
|
||||
AColor: guint;
|
||||
i: Integer;}
|
||||
GDKColor: TGDKColor;
|
||||
GdkColorContext: PGdkColorContext;
|
||||
PixColor: Integer;
|
||||
begin
|
||||
Result:=false;
|
||||
if not IsValidDC(SrcDC) then begin
|
||||
writeln('WARNING: TgtkObject.GetRawImageFromDevice invalid SrcDC');
|
||||
Result:=false;
|
||||
exit;
|
||||
end;
|
||||
FillChar(NewRawImage,SizeOf(NewRawImage),0);
|
||||
|
||||
// get raw image description
|
||||
writeln('TgtkObject.GetRawImageFromDevice A SrcDC=',HexStr(Cardinal(SrcDC),8));
|
||||
Result := GetDeviceRawImageDescription(SrcDC,@NewRawImage.Description);
|
||||
if not Result then exit;
|
||||
|
||||
writeln('TgtkObject.GetRawImageFromDevice B ');
|
||||
// get intersection
|
||||
GdkWindow:=nil;
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(SrcDC));
|
||||
writeln('TgtkObject.GetRawImageFromDevice C DCOrigin=',DCOrigin.X,',',DCOrigin.Y,' SrcRect=',SrcRect.Left,',',SrcRect.Top,',',SrcRect.Right,',',SrcRect.Bottom);
|
||||
writeln('TgtkObject.GetRawImageFromDevice A DCOrigin=',DCOrigin.X,',',DCOrigin.Y,' SrcRect=',SrcRect.Left,',',SrcRect.Top,',',SrcRect.Right,',',SrcRect.Bottom);
|
||||
ARect:=SrcRect;
|
||||
OffSetRect(ARect,DCOrigin.x,DCOrigin.y);
|
||||
writeln('TgtkObject.GetRawImageFromDevice D ARect=',ARect.Left,',',ARect.Top,',',ARect.Right,',',ARect.Bottom,' DevW=',NewRawImage.Description.Width,' DevH=',NewRawImage.Description.Height);
|
||||
MaxRect:=Rect(0,0,NewRawImage.Description.Width,
|
||||
NewRawImage.Description.Height);
|
||||
SourceRect:=ARect;
|
||||
IntersectRect(SourceRect,ARect,MaxRect);
|
||||
writeln('TgtkObject.GetRawImageFromDevice E SourceRect=',SourceRect.Left,',',SourceRect.Top,',',SourceRect.Right,',',SourceRect.Bottom);
|
||||
|
||||
GDKWindow:=PGdkWindow(TDeviceContext(SrcDC).Drawable);
|
||||
NewRawImage.Description.Width:=SourceRect.Right-SourceRect.Left;
|
||||
NewRawImage.Description.Height:=SourceRect.Bottom-SourceRect.Top;
|
||||
writeln('TgtkObject.GetRawImageFromDevice F ',SourceRect.Left,',',SourceRect.Top,',',SourceRect.Right,',',SourceRect.Bottom,' GDKWindow=',HexStr(Cardinal(GDkWindow),8));
|
||||
if (NewRawImage.Description.Width=0) or (NewRawImage.Description.Height=0)
|
||||
then exit;
|
||||
|
||||
// get gdk_image
|
||||
AnImage:=gdk_image_get(GDKWindow,SourceRect.Left,SourceRect.Top,
|
||||
NewRawImage.Description.Width,
|
||||
NewRawImage.Description.Height);
|
||||
if AnImage=nil then begin
|
||||
writeln('WARNING: TgtkObject.GetRawImageFromDevice gdk_image_get failed');
|
||||
exit;
|
||||
end;
|
||||
try
|
||||
// consistency checks
|
||||
if NewRawImage.Description.Depth<>AnImage^.Depth then
|
||||
RaiseGDBException('NewRawImage.Description.Depth<>AnImage^.Depth');
|
||||
if NewRawImage.Description.BitsPerPixel<>AnImage^.bpp then
|
||||
RaiseGDBException('NewRawImage.Description.BitsPerPixel<>AnImage^.bpp');
|
||||
|
||||
NewRawImage.DataSize:=(NewRawImage.Description.BitsPerPixel shr 3)
|
||||
*AnImage^.Width*AnImage^.Height;
|
||||
writeln('TgtkObject.GetRawImageFromDevice F2 Width=',AnImage^.Width,' Height=',AnImage^.Height,' BitsPerPixel=',NewRawImage.Description.BitsPerPixel,' bpl=',AnImage^.bpl);
|
||||
if NewRawImage.DataSize<>AnImage^.bpl*AnImage^.Height then
|
||||
RaiseGDBException('NewRawImage.DataSize<>AnImage^.bpl*AnImage^.Height');
|
||||
|
||||
// copy data
|
||||
NewRawImage.Description.Width:=AnImage^.Width;
|
||||
NewRawImage.Description.Height:=AnImage^.Height;
|
||||
|
||||
{NewRawImage.Description.BitsPerPixel:=SizeOf(GUInt)*8;
|
||||
NewRawImage.DataSize:=AnImage^.Width*AnImage^.Height*SizeOf(GUInt);
|
||||
ReAllocMem(NewRawImage.Data,NewRawImage.DataSize);
|
||||
i:=0;
|
||||
for y:=0 to AnImage^.Height-1 do begin
|
||||
for x:=0 to AnImage^.Width-1 do begin
|
||||
AColor:=gdk_image_get_pixel(AnImage,x,y);
|
||||
pGuint(NewRawImage.Data)[i]:=AColor;
|
||||
if (y=5) then write(' ',HexStr(Cardinal(AColor),8),'@',HexStr(Cardinal(@pGuint(NewRawImage.Data)[i]),8));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
writeln('');}
|
||||
ReAllocMem(NewRawImage.Data,NewRawImage.DataSize);
|
||||
if NewRawImage.DataSize>0 then
|
||||
System.Move(AnImage^.Mem^,NewRawImage.Data^,NewRawImage.DataSize);
|
||||
|
||||
|
||||
writeln('TgtkObject.GetRawImageFromDevice G W=',NewRawImage.Description.Width,' H=',NewRawImage.Description.Height,' Depth=',NewRawImage.Description.Depth,' DataSize=',NewRawImage.DataSize);
|
||||
finally
|
||||
gdk_image_destroy(AnImage);
|
||||
end;
|
||||
|
||||
|
||||
AnImage := gdk_image_get(GDKWindow,5,5,1,1);
|
||||
GDKColor.Pixel := gdk_image_get_pixel(AnImage,0,0);
|
||||
writeln('TgtkObject.GetRawImageFromDevice H ',HexStr(Cardinal(GDKColor.Pixel),8));
|
||||
gdk_image_destroy(AnImage);
|
||||
|
||||
GdkColorContext:=
|
||||
gdk_color_context_new(gdk_visual_get_system,gdk_colormap_get_system);
|
||||
gdk_color_context_query_color(GdkColorContext,@GDKColor);
|
||||
gdk_color_context_free(GdkColorContext);
|
||||
|
||||
PixColor := TGDKColorToTColor(GDKColor);
|
||||
writeln('TgtkObject.GetRawImageFromDevice I ',HexStr(Cardinal(PixColor),8));
|
||||
|
||||
|
||||
Result:=true;
|
||||
Result:=GetRawImageFromGdkWindow(GDKWindow,ARect,NewRawImage);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -4206,7 +4176,7 @@ var
|
||||
GdkPixmap: PGdkPixmap;
|
||||
GDIMaskImg: PGDIObject;
|
||||
GdkMaskBitmap: PGdkPixmap;
|
||||
MaskDescription: TRawImageDescription;
|
||||
MaskRawImage: TRawImage;
|
||||
begin
|
||||
Result:=false;
|
||||
FillChar(NewRawImage,SizeOf(NewRawImage),0);
|
||||
@ -4219,8 +4189,8 @@ begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] invalid MaskBitmap!');
|
||||
exit;
|
||||
end;
|
||||
|
||||
// get Bitmap gdkwindow
|
||||
|
||||
// get rawimage for Bitmap
|
||||
GDIImg:=PGDIObject(SrcBitmap);
|
||||
GdkPixmap:=nil;
|
||||
case GDIImg^.GDIBitmapType of
|
||||
@ -4230,42 +4200,51 @@ begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] GDI_RGBImage not implemented');
|
||||
exit;
|
||||
end;
|
||||
|
||||
// get MaskBitmap gdkwindow
|
||||
GDIMaskImg:=PGDIObject(SrcBitmap);
|
||||
GdkMaskBitmap:=nil;
|
||||
if GDIMaskImg<>nil then begin
|
||||
case GDIMaskImg^.GDIBitmapType of
|
||||
gbBitmap: GdkMaskBitmap:=PGdkPixmap(GDIMaskImg^.GDIBitmapObject);
|
||||
else
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] invalid MaskBitmap');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// get raw image description for Bitmap
|
||||
Result:=GetWindowRawImageDescription(PGdkWindow(GdkPixmap),
|
||||
@NewRawImage.Description);
|
||||
if not Result then exit;
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] A GdkPixmap=',HexStr(Cardinal(GdkPixmap),8));
|
||||
if not GetRawImageFromGdkWindow(PGdkWindow(GdkPixmap),SrcRect,NewRawImage)
|
||||
then exit;
|
||||
|
||||
// get raw image description for MaskBitmap
|
||||
if GdkMaskBitmap<>nil then begin
|
||||
Result:=GetWindowRawImageDescription(PGdkWindow(GdkMaskBitmap),
|
||||
@MaskDescription);
|
||||
if not Result then exit;
|
||||
// check if mask compatible
|
||||
if (MaskDescription.Width<>NewRawImage.Description.Width)
|
||||
or (MaskDescription.Height<>NewRawImage.Description.Height) then begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] MaskBitmap has different Size than Bitmap');
|
||||
exit;
|
||||
end;
|
||||
if (MaskDescription.Depth<>1) then begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] MaskBitmap Depth<>1');
|
||||
exit;
|
||||
end;
|
||||
// the bitmap is ready. If there is no mask the rawimage is complete
|
||||
if SrcMaskBitmap=0 then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
|
||||
// get rawimage for MaskBitmap
|
||||
GDIMaskImg:=PGDIObject(SrcMaskBitmap);
|
||||
GdkMaskBitmap:=nil;
|
||||
case GDIMaskImg^.GDIBitmapType of
|
||||
gbBitmap: GdkMaskBitmap:=PGdkPixmap(GDIMaskImg^.GDIBitmapObject);
|
||||
else
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] invalid MaskBitmap');
|
||||
exit;
|
||||
end;
|
||||
if not GetRawImageFromGdkWindow(PGdkWindow(GdkMaskBitmap),SrcRect,
|
||||
MaskRawImage)
|
||||
then exit;
|
||||
|
||||
// check if mask is compatible
|
||||
if (MaskRawImage.Description.Width<>NewRawImage.Description.Width)
|
||||
or (MaskRawImage.Description.Height<>NewRawImage.Description.Height) then begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] MaskBitmap has different Size than Bitmap');
|
||||
exit;
|
||||
end;
|
||||
if (MaskRawImage.Description.Depth<>1) then begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] MaskBitmap Depth<>1');
|
||||
exit;
|
||||
end;
|
||||
if (MaskRawImage.Description.HasPalette) then begin
|
||||
writeln('WARNING: [TgtkObject.GetRawImageFromBitmap] MaskBitmap HasPalette');
|
||||
exit;
|
||||
end;
|
||||
|
||||
// merge mask
|
||||
if NewRawImage.Mask<>nil then FreeMem(NewRawImage.Mask);
|
||||
NewRawImage.Mask:=MaskRawImage.Data;
|
||||
NewRawImage.MaskSize:=MaskRawImage.DataSize;
|
||||
NewRawImage.Description.AlphaMask:=true;
|
||||
NewRawImage.Description.AlphaPrec:=MaskRawImage.Description.Depth;
|
||||
NewRawImage.Description.AlphaShift:=0;
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
@ -8530,6 +8509,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.256 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.255 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -48,6 +48,7 @@ function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; ove
|
||||
Function CombineRgn(Dest, Src1, Src2 : HRGN; fnCombineMode : Longint) : Longint; override;
|
||||
function ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean; override;
|
||||
function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
|
||||
function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap): boolean; override;
|
||||
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
|
||||
function CreateCaret(Handle : HWND; Bitmap : hBitmap; width, Height : Integer) : Boolean; override;
|
||||
function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; override;
|
||||
@ -209,6 +210,9 @@ Procedure DeleteCriticalSection(var CritSection: TCriticalSection); Override;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.72 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.71 2003/07/02 10:02:51 mattias
|
||||
fixed TPaintStruct
|
||||
|
||||
|
@ -228,7 +228,7 @@ Procedure TWin32Object.SetLabel(Sender: TObject; Data: Pointer);
|
||||
cbsize:=sizeof(MENUITEMINFO);
|
||||
{In Win32 Menu items that are created without a initial caption default to disabled,
|
||||
the next three lines are to counter that.}
|
||||
fMask:=MIIM_STATE or MIIM_TYPE or MIIM_ID;
|
||||
fMask:=MIIM_STATE;
|
||||
GetMenuItemInfo((Sender as TMenuItem).Parent.Handle,
|
||||
(Sender as TMenuItem).Command, false, @MenuInfo);
|
||||
if (Sender as TMenuItem).Enabled then
|
||||
@ -2672,6 +2672,9 @@ End;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.65 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.64 2003/07/01 22:02:55 mattias
|
||||
fixed formstyle and redrawing from Micha
|
||||
|
||||
|
@ -100,6 +100,20 @@ Begin
|
||||
Result := Windows.BitBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Rop);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: BeginPaint
|
||||
Params: Handle - Handle to window to begin painting in
|
||||
PS - PAINTSTRUCT variable that will receive painting information.
|
||||
Returns: A device context for the specified window if succesful otherwise nil
|
||||
|
||||
The BeginPaint function prepares the specified window for painting and fills
|
||||
a PAINTSTRUCT structure with information about the painting.
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32Object.BeginPaint(Handle : hwnd; var PS : TPaintStruct): hdc;
|
||||
Begin
|
||||
Result := Windows.BeginPaint(Handle, @PS);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: BringWindowToTop
|
||||
Params: HWnd - The handle of the window
|
||||
@ -844,6 +858,21 @@ Begin
|
||||
Result := Windows.EnableScrollBar(Wnd, WSBFlags, WArrows);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: EndPaint
|
||||
Params: Handle - Handle to window
|
||||
PS - PAINTSTRUCT variable with painting information
|
||||
Returns: always nonzero.
|
||||
|
||||
The EndPaint function marks the end of painting in the specified window.
|
||||
This function is required for each call to the BeginPaint function, but only
|
||||
after painting is complete.
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32Object.EndPaint(Handle : hwnd; var PS : TPaintStruct): Integer;
|
||||
Begin
|
||||
Result := Integer(Windows.EndPaint(Handle, @PS));
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: EnableWindow
|
||||
Params: HWnd - handle to window
|
||||
@ -2237,24 +2266,24 @@ var
|
||||
begin
|
||||
{ An OS Compatible TCriticalSection needs to be defined}
|
||||
If CritSection <> 0 then
|
||||
Try
|
||||
{ Try
|
||||
Crit := LPCRITICAL_SECTION(CritSection);
|
||||
Dispose(Crit);
|
||||
except
|
||||
CritSection := 0;
|
||||
end;
|
||||
end;}
|
||||
New(Crit);
|
||||
Windows.InitializeCriticalSection(Crit^);
|
||||
CritSection := Longint(Crit);
|
||||
end;
|
||||
|
||||
Procedure TWin32Object.EnterCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
{var
|
||||
Crit,
|
||||
tmp : LPCRITICAL_SECTION;
|
||||
tmp : LPCRITICAL_SECTION;}
|
||||
begin
|
||||
{ An OS Compatible TCriticalSection needs to be defined}
|
||||
New(Crit);
|
||||
{ New(Crit);
|
||||
If CritSection <> 0 then
|
||||
Try
|
||||
Crit^ := LPCRITICAL_SECTION(CritSection)^;
|
||||
@ -2267,16 +2296,16 @@ begin
|
||||
Windows.EnterCriticalSection(Crit^);
|
||||
tmp := LPCRITICAL_SECTION(CritSection);
|
||||
CritSection := Longint(Crit);
|
||||
Dispose(Tmp);
|
||||
Dispose(Tmp);}
|
||||
end;
|
||||
|
||||
Procedure TWin32Object.LeaveCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
{var
|
||||
Crit,
|
||||
tmp : LPCRITICAL_SECTION;
|
||||
tmp : LPCRITICAL_SECTION;}
|
||||
begin
|
||||
{ An OS Compatible TCriticalSection needs to be defined}
|
||||
New(Crit);
|
||||
{ New(Crit);
|
||||
If CritSection <> 0 then
|
||||
Try
|
||||
Crit^ := LPCRITICAL_SECTION(CritSection)^;
|
||||
@ -2289,16 +2318,16 @@ begin
|
||||
Windows.LeaveCriticalSection(Crit^);
|
||||
tmp := LPCRITICAL_SECTION(CritSection);
|
||||
CritSection := Longint(Crit);
|
||||
Dispose(Tmp);
|
||||
Dispose(Tmp);}
|
||||
end;
|
||||
|
||||
Procedure TWin32Object.DeleteCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
{var
|
||||
Crit,
|
||||
tmp : LPCRITICAL_SECTION;
|
||||
tmp : LPCRITICAL_SECTION;}
|
||||
begin
|
||||
{ An OS Compatible TCriticalSection needs to be defined}
|
||||
New(Crit);
|
||||
{ New(Crit);
|
||||
If CritSection <> 0 then
|
||||
Try
|
||||
Crit^ := LPCRITICAL_SECTION(CritSection)^;
|
||||
@ -2312,7 +2341,7 @@ begin
|
||||
Dispose(Crit);
|
||||
tmp := LPCRITICAL_SECTION(CritSection);
|
||||
CritSection := 0;
|
||||
Dispose(Tmp);
|
||||
Dispose(Tmp);}
|
||||
end;
|
||||
|
||||
//##apiwiz##eps## // Do not remove
|
||||
@ -2325,6 +2354,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.36 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.35 2003/06/28 16:20:19 mattias
|
||||
fixed some win32 intf warnings
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
Function Arc(DC: HDC; X, Y, Width, Height, Angle1, Angle2: Integer): Boolean; Override;
|
||||
function AngleChord(DC: HDC; x,y,width,height,angle1,angle2 : Integer): Boolean; override;
|
||||
|
||||
Function BeginPaint(Handle : hwnd; var PS : TPaintStruct): hdc; Override;
|
||||
Function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; Override;
|
||||
Function BringWindowToTop(HWnd: HWND): Boolean; Override;
|
||||
|
||||
@ -68,6 +69,7 @@ Function EmptyClipBoard: Boolean;
|
||||
Function EnableMenuItem(HndMenu: HMENU; UIDEnableItem: Integer; BEnable: Boolean): Boolean; Override;
|
||||
Function EnableScrollBar(Wnd: HWND; WSBFlags, WArrows: Cardinal): Boolean; Override;
|
||||
Function EnableWindow(HWnd: HWND; BEnable: Boolean): Boolean; Override;
|
||||
Function EndPaint(Handle : hwnd; var PS : TPaintStruct): Integer; Override;
|
||||
Function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||
Function ExtTextOut(DC: HDC; X, Y: Integer; Options: LongInt; Rect: PRect; Str: PChar; Count: LongInt; Dx: PInteger): Boolean; Override;
|
||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||
@ -173,6 +175,9 @@ Procedure DeleteCriticalSection(var CritSection: TCriticalSection); Override;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.24 2003/07/02 15:56:15 mattias
|
||||
fixed win32 painting and started creating bitmaps from rawimages
|
||||
|
||||
Revision 1.23 2003/03/25 08:12:39 mattias
|
||||
patch from Martin Smat for menu items and default messages
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user