summaryrefslogtreecommitdiff
path: root/plugins/Pascal_Headers/reserve/imgdecoder.pas
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-06-29 06:56:07 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-06-29 06:56:07 +0000
commita2795725f5afc756a405a85c192bdd53b967999d (patch)
tree08548adc194d0c2a960120a342bac02208c3e23f /plugins/Pascal_Headers/reserve/imgdecoder.pas
parentaf7e438cfe8ce85e1da234318ed1584e89d952cc (diff)
Added my Miranda API pascal version
Changed ShlExt to my API compilation (32 bit FPC now only) git-svn-id: http://svn.miranda-ng.org/main/trunk@679 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Pascal_Headers/reserve/imgdecoder.pas')
-rw-r--r--plugins/Pascal_Headers/reserve/imgdecoder.pas114
1 files changed, 114 insertions, 0 deletions
diff --git a/plugins/Pascal_Headers/reserve/imgdecoder.pas b/plugins/Pascal_Headers/reserve/imgdecoder.pas
new file mode 100644
index 0000000000..eea6ec2610
--- /dev/null
+++ b/plugins/Pascal_Headers/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.
+}