From a2795725f5afc756a405a85c192bdd53b967999d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Fri, 29 Jun 2012 06:56:07 +0000 Subject: 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 --- plugins/Pascal_Headers/reserve/imgdecoder.pas | 114 ++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 plugins/Pascal_Headers/reserve/imgdecoder.pas (limited to 'plugins/Pascal_Headers/reserve/imgdecoder.pas') 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. +} -- cgit v1.2.3