summaryrefslogtreecommitdiff
path: root/include/delphi/reserve/imgdecoder.pas
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-07-04 20:10:29 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-07-04 20:10:29 +0000
commit65e002b63efdb00571d0ba4ec1a73b14e1d7d3a0 (patch)
treed96b2f52ca3c89172f269cdb172c89cf6141d69c /include/delphi/reserve/imgdecoder.pas
parentd7f143dba9e53347a1d7897bcd3989751c7f45f8 (diff)
Pascal headers moved to include\delphi directory (with small updates)
removed deprecated m_mwclc.h file and link on it in AutoShutdown plugin git-svn-id: http://svn.miranda-ng.org/main/trunk@763 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/delphi/reserve/imgdecoder.pas')
-rw-r--r--include/delphi/reserve/imgdecoder.pas114
1 files changed, 114 insertions, 0 deletions
diff --git a/include/delphi/reserve/imgdecoder.pas b/include/delphi/reserve/imgdecoder.pas
new file mode 100644
index 0000000000..eea6ec2610
--- /dev/null
+++ b/include/delphi/reserve/imgdecoder.pas
@@ -0,0 +1,114 @@
+unit ImgDecoder;
+
+interface
+uses Windows;
+
+function IsImgDecoderAvailable:boolean;
+function ImgNewDecoder(var pDecoder:pointer):dword;
+function ImgDeleteDecoder(pDecoder:pointer):dword;
+function ImgNewDIBFromFile(pDecoder:pointer;Filename:PAnsiChar;var pImg:pointer):dword;
+function ImgDeleteDIBSection(pImg:pointer):dword;
+function ImgGetHandle(pImg:pointer;var pBitmap:HBITMAP;var ppDIBBits:pointer):dword;
+
+implementation
+
+const
+ hModule:THANDLE=0;
+type
+ tImgNewDecoder =function(var pDecoder:pointer):dword; stdcall;
+ tImgDeleteDecoder =function(pDecoder:pointer):dword; stdcall;
+ tImgNewDIBFromFile =function(pDecoder:pointer;Filename:PAnsiChar;var pImg):dword; stdcall;
+ tImgDeleteDIBSection=function(pImg:pointer):dword; stdcall;
+ tImgGetHandle =function(pImg:pointer;var pBitmap:HBITMAP;var ppDIBBits:pointer):dword; stdcall;
+
+const
+ pImgNewDecoder :tImgNewDecoder = nil;
+ pImgDeleteDecoder :tImgDeleteDecoder = nil;
+ pImgNewDIBFromFile :tImgNewDIBFromFile = nil;
+ pImgDeleteDIBSection:tImgDeleteDIBSection = nil;
+ pImgGetHandle :tImgGetHandle = nil;
+
+function IsImgDecoderAvailable:boolean;
+begin
+ result:=hModule<>0;
+end;
+
+function ImgNewDecoder(var pDecoder:pointer):dword;
+begin
+ if @pImgNewDecoder<>nil then
+ result:=pImgNewDecoder(pDecoder)
+ else
+ result:=0;
+end;
+
+function ImgDeleteDecoder(pDecoder:pointer):dword;
+begin
+ if @pImgDeleteDecoder<>nil then
+ result:=pImgDeleteDecoder(pDecoder)
+ else
+ result:=0;
+end;
+
+function ImgNewDIBFromFile(pDecoder:pointer;Filename:PAnsiChar;var pImg:pointer):dword;
+begin
+ if @pImgNewDecoder<>nil then
+ result:=pImgNewDIBFromFile(pDecoder,Filename,pImg)
+ else
+ result:=0;
+end;
+
+function ImgDeleteDIBSection(pImg:pointer):dword;
+begin
+ if @pImgNewDecoder<>nil then
+ result:=pImgDeleteDIBSection(pImg)
+ else
+ result:=0;
+end;
+
+function ImgGetHandle(pImg:pointer;var pBitmap:HBITMAP;var ppDIBBits:pointer):dword;
+begin
+ if @pImgGetHandle<>nil then
+ result:=pImgGetHandle(pImg,pBitmap,ppDIBBits)
+ else
+ result:=0;
+end;
+
+initialization
+ hModule:=LoadLibrary('imgdecoder.dll');
+ if hModule=0 then
+ hModule:=LoadLibrary('plugins\imgdecoder.dll');
+
+ if hModule<>0 then
+ begin
+ pImgNewDecoder :=GetProcAddress(hModule, 'ImgNewDecoder');
+ pImgDeleteDecoder :=GetProcAddress(hModule, 'ImgDeleteDecoder');
+ pImgNewDIBFromFile :=GetProcAddress(hModule, 'ImgNewDIBFromFile');
+ pImgDeleteDIBSection:=GetProcAddress(hModule, 'ImgDeleteDIBSection');
+ pImgGetHandle :=GetProcAddress(hModule, 'ImgGetHandle');
+ end;
+
+finalization
+ if hModule<>0 then
+ FreeLibrary(hModule);
+end.
+{ Sample of using
+
+var
+ pDecoder:pointer;
+ pImg:pointer;
+ bitmap:HBITMAP;
+ pBits:pointer;
+begin
+ if IsImgDecoderAvailable then
+ begin
+ ImgNewDecoder(pDecoder);
+ if ImgNewDIBFromFile(pDecoder,PAnsiChar(ParamStr(1)),pImg)<>0 then
+ begin
+ ImgGetHandle(pImg,bitmap,pBits);
+// action
+ ImgDeleteDIBSection(pImg);
+ end;
+ ImgDeleteDecoder(pDecoder);
+ end;
+end.
+}