added fpImage reader/writer hooks to TBitmap

git-svn-id: trunk@4581 -
This commit is contained in:
mattias 2003-09-08 12:21:48 +00:00
parent 9d8709e7c1
commit bf6c4c8362
7 changed files with 91 additions and 81 deletions

View File

@ -886,6 +886,10 @@ type
ReaderClass: TFPCustomImageReaderClass); virtual; ReaderClass: TFPCustomImageReaderClass); virtual;
procedure WriteStreamWithFPImage(Stream: TStream; WriteSize: boolean; procedure WriteStreamWithFPImage(Stream: TStream; WriteSize: boolean;
WriterClass: TFPCustomImageWriterClass); virtual; WriterClass: TFPCustomImageWriterClass); virtual;
procedure InitFPImageReader(ImgReader: TFPCustomImageReader); virtual;
procedure InitFPImageWriter(ImgWriter: TFPCustomImageWriter); virtual;
procedure FinalizeFPImageReader(ImgReader: TFPCustomImageReader); virtual;
procedure FinalizeFPImageWriter(ImgWriter: TFPCustomImageWriter); virtual;
{$ENDIF} {$ENDIF}
public public
constructor VirtualCreate; override; constructor VirtualCreate; override;
@ -1194,6 +1198,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.88 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.87 2003/09/05 21:27:28 mattias Revision 1.87 2003/09/05 21:27:28 mattias
fixed types fixed types

View File

@ -679,8 +679,10 @@ begin
IntfImg:=TLazIntfImage.Create(0,0); IntfImg:=TLazIntfImage.Create(0,0);
IntfImg.GetDescriptionFromDevice(0); IntfImg.GetDescriptionFromDevice(0);
ImgReader:=ReaderClass.Create; ImgReader:=ReaderClass.Create;
InitFPImageReader(ImgReader);
FImage.SaveStream.Position:=0; FImage.SaveStream.Position:=0;
IntfImg.LoadFromStream(FImage.SaveStream,ImgReader); IntfImg.LoadFromStream(FImage.SaveStream,ImgReader);
FinalizeFPImageReader(ImgReader);
IntfImg.CreateBitmap(ImgHandle,ImgMaskHandle); IntfImg.CreateBitmap(ImgHandle,ImgMaskHandle);
Handle:=ImgHandle; Handle:=ImgHandle;
MaskHandle:=ImgMaskHandle; MaskHandle:=ImgMaskHandle;
@ -724,7 +726,9 @@ begin
IntfImg:=TLazIntfImage.Create(0,0); IntfImg:=TLazIntfImage.Create(0,0);
IntfImg.LoadFromBitmap(Handle,0); IntfImg.LoadFromBitmap(Handle,0);
ImgWriter:=WriterClass.Create; ImgWriter:=WriterClass.Create;
InitFPImageWriter(ImgWriter);
IntfImg.SaveToStream(MemStream,ImgWriter); IntfImg.SaveToStream(MemStream,ImgWriter);
FinalizeFPImageWriter(ImgWriter);
FreeAndNil(ImgWriter); FreeAndNil(ImgWriter);
FreeAndNil(IntfImg); FreeAndNil(IntfImg);
// save stream, so that further saves will be fast // save stream, so that further saves will be fast
@ -740,6 +744,27 @@ begin
ImgWriter.Free; ImgWriter.Free;
end; end;
end; end;
procedure TBitmap.InitFPImageReader(ImgReader: TFPCustomImageReader);
begin
end;
procedure TBitmap.InitFPImageWriter(ImgWriter: TFPCustomImageWriter);
begin
end;
procedure TBitmap.FinalizeFPImageReader(ImgReader: TFPCustomImageReader);
begin
end;
procedure TBitmap.FinalizeFPImageWriter(ImgWriter: TFPCustomImageWriter);
begin
end;
{$ENDIF} {$ENDIF}
procedure TBitMap.SaveToStream(Stream: TStream); procedure TBitMap.SaveToStream(Stream: TStream);
@ -854,6 +879,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.44 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.43 2003/09/05 22:13:40 mattias Revision 1.43 2003/09/05 22:13:40 mattias
implemented TBitmap.Assign(TFPCustomImage) implemented TBitmap.Assign(TFPCustomImage)

View File

@ -85,7 +85,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TFileDialog.SetFilter(const value : string); procedure TFileDialog.SetFilter(const value : string);
begin begin
FFilter := value; // make sure this is defined first before the CNSendMessage FFilter := Value; // make sure this is defined first before the CNSendMessage
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -265,6 +265,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.12 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.11 2003/09/02 21:32:56 mattias Revision 1.11 2003/09/02 21:32:56 mattias
implemented TOpenPictureDialog implemented TOpenPictureDialog

View File

@ -684,27 +684,6 @@ Begin
Assert(False, 'Trace:WindowProc - Exit'); Assert(False, 'Trace:WindowProc - Exit');
End; End;
{------------------------------------------------------------------------------
Function: TimerWindowProc
Params: Window - The window that receives a message for the timer window
Msg - The message received
WParam - Word parameter
LParam - Long-integer parameter
Returns: 0 if Msg is handled; non-zero long-integer result otherwise
Handles the messages sent to the timer window by Windows
------------------------------------------------------------------------------}
FUNCTION TimerWindowProc(window_hwnd : hwnd; msg : DWORD; wParam : WPARAM; lParam : LPARAM) : LRESULT; stdcall;
Var
TimerInfo: PWin32TimerInfo;
begin
if (msg = WM_TIMER) and (WParam<>0) then begin
TimerInfo := PWin32TimerInfo(WParam);
TimerInfo^.TimerFunc;
Result := 0;
end else Result := DefWindowProc(window_hwnd, Msg, WParam, LParam);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: ToolBtnWindowProc Function: ToolBtnWindowProc
Params: Window_hwnd - The window that receives a message for the window Params: Window_hwnd - The window that receives a message for the window
@ -720,6 +699,29 @@ begin
Result := DefWindowProc(window_hwnd, Msg, WParam, LParam); Result := DefWindowProc(window_hwnd, Msg, WParam, LParam);
end; end;
{------------------------------------------------------------------------------
Procedure: TimerCallBackProc
Params: window_hnd - handle of window for timer message, not set in this implementation
msg - WM_TIMER message
idEvent - timer identifier
dwTime - current system time
Calls the timerfunction in the Timer Object in the LCL
------------------------------------------------------------------------------}
Procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall;
Var
TimerInfo: PWin32TimerInfo;
n: Integer;
begin
n := FTimerData.Count;
while (n>0) do begin
dec(n);
TimerInfo := FTimerData[n];
if TimerInfo^.TimerID=idEvent
then TimerInfo^.TimerFunc;
end;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: BrowseForFolderCallback Function: BrowseForFolderCallback
Params: Window_hwnd - The window that receives a message for the window Params: Window_hwnd - The window that receives a message for the window
@ -752,6 +754,9 @@ end;
{ {
$Log$ $Log$
Revision 1.56 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.55 2003/08/25 16:18:15 mattias Revision 1.55 2003/08/25 16:18:15 mattias
fixed background color of TPanel and clicks of TSpeedButton from Micha fixed background color of TPanel and clicks of TSpeedButton from Micha

View File

@ -116,8 +116,8 @@ type
{ lazarus win32 Interface definition for additional timer data needed to find the callback} { lazarus win32 Interface definition for additional timer data needed to find the callback}
PWin32TimerInfo = ^TWin32Timerinfo; PWin32TimerInfo = ^TWin32Timerinfo;
TWin32TimerInfo = record TWin32TimerInfo = record
TimerHandle: uint; // the windows timer ID for this timer TimerID: UINT; // the windows timer ID for this timer
TimerFunc : TFNTimerProc; // owner function to handle timer TimerFunc: TFNTimerProc; // owner function to handle timer
end; end;
var var
@ -131,6 +131,9 @@ End.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.7 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.6 2003/08/17 12:26:00 mattias Revision 1.6 2003/08/17 12:26:00 mattias
fixed parts of the win32 intf size system fixed parts of the win32 intf size system

View File

@ -59,7 +59,6 @@ Type
FGDIObjects: TDynHashArray; FGDIObjects: TDynHashArray;
FMessageQueue: TList; FMessageQueue: TList;
FToolTipWindow: HWND; FToolTipWindow: HWND;
FTimerWindow: HWND;
FAccelGroup: HACCEL; FAccelGroup: HACCEL;
FControlIndex: Cardinal; // Win32-API control index FControlIndex: Cardinal; // Win32-API control index
FMainForm: TForm; FMainForm: TForm;
@ -99,7 +98,6 @@ Type
Procedure AttachMenu(Sender: TObject); Procedure AttachMenu(Sender: TObject);
Function WinRegister: Boolean; Function WinRegister: Boolean;
Function TimerWinRegister: Boolean;
Function ToolBtnWinRegister: Boolean; Function ToolBtnWinRegister: Boolean;
Procedure SetOwner(Window: HWND; Owner: TObject); Procedure SetOwner(Window: HWND; Owner: TObject);
Procedure PaintPixmap(Surface: TObject; PixmapData: Pointer); Procedure PaintPixmap(Surface: TObject; PixmapData: Pointer);
@ -116,6 +114,7 @@ Type
{ Constructor of the class } { Constructor of the class }
Constructor Create; Constructor Create;
class function CreateVirtual: TInterfaceBase; override;
{ Destructor of the class } { Destructor of the class }
Destructor Destroy; Override; Destructor Destroy; Override;
{ Initialize the API } { Initialize the API }
@ -161,7 +160,6 @@ Type
Const Const
BOOL_RESULT: Array[Boolean] Of String = ('False', 'True'); BOOL_RESULT: Array[Boolean] Of String = ('False', 'True');
ClsName : array[0..20] of char = 'LazarusForm'#0; ClsName : array[0..20] of char = 'LazarusForm'#0;
TimerClsName : array[0..20] of char = 'LCLTimerWindow'#0;
ToolBtnClsName : array[0..20] of char = 'ToolbarButton'#0; ToolBtnClsName : array[0..20] of char = 'ToolbarButton'#0;
Var Var
@ -189,6 +187,9 @@ End.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.38 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.37 2003/08/28 09:10:01 mattias Revision 1.37 2003/08/28 09:10:01 mattias
listbox and comboboxes now set sort and selection at handle creation listbox and comboboxes now set sort and selection at handle creation

View File

@ -37,7 +37,6 @@ Begin
FMessageQueue := TList.Create; FMessageQueue := TList.Create;
FAccelGroup := 0; FAccelGroup := 0;
FTimerData := TList.Create; FTimerData := TList.Create;
FTimerWindow := 0;
// Retrieves the height of a win32 menu // Retrieves the height of a win32 menu
With R1 do With R1 do
begin begin
@ -73,18 +72,11 @@ Begin
while (n > 0) do while (n > 0) do
begin begin
dec(n); dec(n);
TimerInfo := PWin32Timerinfo (FTimerData.Items[n]); TimerInfo := PWin32Timerinfo(FTimerData[n]);
Dispose (TimerInfo); Dispose(TimerInfo);
FTimerData.Delete(n); FTimerData.Delete(n);
end; end;
end; end;
Assert(False,'Trace:FTimerWindow: ' + IntToStr(FTimerWindow));
if FTimerWindow<>0 then
begin
DestroyWindow(FTimerWindow);
FTimerWindow := 0;
end;
if FToolTipWindow <> 0 then if FToolTipWindow <> 0 then
begin begin
@ -112,7 +104,6 @@ Begin
DestroyAcceleratorTable(FAccelGroup); DestroyAcceleratorTable(FAccelGroup);
Windows.UnregisterClass(@ClsName, System.HInstance); Windows.UnregisterClass(@ClsName, System.HInstance);
Windows.UnregisterClass(@TimerClsName, System.HInstance);
Windows.UnregisterClass(@ToolBtnClsName, System.HInstance); Windows.UnregisterClass(@ToolBtnClsName, System.HInstance);
Inherited Destroy; Inherited Destroy;
@ -136,11 +127,6 @@ Begin
writeln('Trace:Win32Object.Init - Register Failed'); writeln('Trace:Win32Object.Init - Register Failed');
Exit; Exit;
End; End;
If Not TimerWinRegister then
Begin
Assert(False, 'Trace:Win32Object.Init - LCLTimerWindow Register Failed');
Exit;
End;
If Not ToolBtnWinRegister then If Not ToolBtnWinRegister then
Begin Begin
Assert(False, 'Trace:Win32Object.Init - Toolbar button Register Failed'); Assert(False, 'Trace:Win32Object.Init - Toolbar button Register Failed');
@ -150,9 +136,6 @@ Begin
FToolTipWindow := CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, FParentWindow, HMENU(nil), HInstance, nil); FToolTipWindow := CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, FParentWindow, HMENU(nil), HInstance, nil);
Windows.SendMessage(FParentWindow, TTM_ACTIVATE, WPARAM(True), 0); Windows.SendMessage(FParentWindow, TTM_ACTIVATE, WPARAM(True), 0);
FTimerWindow :=CreateWindowEx(0, @TimerClsName, nil, WS_POPUPWINDOW, 0, 0, 640, 480, 0, 0, System.HInstance, nil);
Assert(False,'Trace:FTimerWindow: ' + IntToStr(FTimerWindow));
//Init stock objects; //Init stock objects;
LogBrush.lbStyle := BS_NULL; LogBrush.lbStyle := BS_NULL;
FStockNullBrush := CreateBrushIndirect(LogBrush); FStockNullBrush := CreateBrushIndirect(LogBrush);
@ -1167,9 +1150,8 @@ End;
TimerFunc: Callback TimerFunc: Callback
Returns: a Timer id (use this ID to destroy timer) Returns: a Timer id (use this ID to destroy timer)
Design: A timer which sends a wm_timr is created, Design: A timer which calls TimerCallBackProc, is created.
the wm_timer is received by a hidden window, The TimerCallBackProc calls the TimerFunc.
which calls the TimerFunc in its window proc.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32Object.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; function TWin32Object.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer;
var var
@ -1177,16 +1159,15 @@ var
begin begin
Assert(False,'Trace:Create Timer: ' + IntToStr(Interval)); Assert(False,'Trace:Create Timer: ' + IntToStr(Interval));
Result := 0; Result := 0;
if (FTimerWindow<>0) and (Interval >= 1) and (TimerFunc <> nil) if (Interval > 0) and (TimerFunc <> nil) then begin
then begin
New(TimerInfo); New(TimerInfo);
TimerInfo^.TimerFunc := TimerFunc; TimerInfo^.TimerFunc := TimerFunc;
Result:= Windows.SetTimer(FTimerWindow,integer(TimerInfo),Interval,nil); TimerInfo^.TimerID := Windows.SetTimer(0, 0, Interval, @TimerCallBackProc);
if Result = 0 then if TimerInfo^.TimerID=0 then
Dispose(TimerInfo) dispose(TimerInfo)
else begin else begin
TimerInfo^.TimerHandle:= Result;
FTimerData.Add(TimerInfo); FTimerData.Add(TimerInfo);
Result := TimerInfo^.TimerID;
end; end;
end; end;
Assert(False,'Trace:Result: ' + IntToStr(result)); Assert(False,'Trace:Result: ' + IntToStr(result));
@ -1205,12 +1186,12 @@ begin
Result:= false; Result:= false;
Assert(False,'Trace:removing timer: '+ IntToStr(TimerHandle)); Assert(False,'Trace:removing timer: '+ IntToStr(TimerHandle));
n := FTimerData.Count; n := FTimerData.Count;
while (n > 0) do begin while (n>0) do begin
dec (n); dec(n);
TimerInfo := PWin32Timerinfo(FTimerData.Items[n]); TimerInfo := FTimerData[n];
if (TimerInfo^.TimerHandle=TimerHandle) then if (TimerInfo^.TimerID=TimerHandle) then
begin begin
result := Windows.KillTimer(FTimerWindow, integer(TimerInfo)); Result := Windows.KillTimer(0, TimerHandle);
FTimerData.Delete(n); FTimerData.Delete(n);
Dispose(TimerInfo); Dispose(TimerInfo);
end; end;
@ -1249,27 +1230,6 @@ Begin
Assert(False, 'Trace:WinRegister - Exit'); Assert(False, 'Trace:WinRegister - Exit');
End; End;
Function TWin32Object.TimerWinRegister: boolean;
var
WinClass: WndClassEx;
begin
with WinClass do begin
cbSize := Sizeof(WndClassEx);
Style := 0{CS_HRedraw or CS_VRedraw};
lpfnWndProc := @TimerWindowProc;
cbClsExtra := 0;
cbWndExtra := 0;
hInstance := System.HInstance;
_hIcon := LoadIcon(0, IDI_Application);
hCursor := LoadCursor(0, IDC_Arrow);
hbrBackground := GetStockObject(LTGRAY_BRUSH);
lpszMenuName := nil;
lpszClassName := @TimerClsName;
hIconSm := LoadIcon(0, IDI_APPLICATION);
end;
result := RegisterClassEx(@WinClass) <> 0;
end;
Function TWin32Object.ToolBtnWinRegister: boolean; Function TWin32Object.ToolBtnWinRegister: boolean;
var WinClass: WndClass; var WinClass: WndClass;
begin begin
@ -2793,6 +2753,9 @@ End;
{ {
$Log$ $Log$
Revision 1.106 2003/09/08 12:21:48 mattias
added fpImage reader/writer hooks to TBitmap
Revision 1.105 2003/09/06 18:37:18 mattias Revision 1.105 2003/09/06 18:37:18 mattias
fixed checkbox state and typecast bugs fixed checkbox state and typecast bugs