* some fixes
git-svn-id: https://svn.code.sf.net/p/kolmck/code@142 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
This commit is contained in:
@@ -35,7 +35,6 @@ type
|
|||||||
procedure SetMax(M: integer);
|
procedure SetMax(M: integer);
|
||||||
protected
|
protected
|
||||||
{ Protected declarations }
|
{ Protected declarations }
|
||||||
procedure Paint;
|
|
||||||
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
||||||
procedure WMSize (var Msg: TMessage); message WM_SIZE;
|
procedure WMSize (var Msg: TMessage); message WM_SIZE;
|
||||||
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
||||||
@@ -45,6 +44,7 @@ type
|
|||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
constructor Create(Owner: TComponent); override;
|
constructor Create(Owner: TComponent); override;
|
||||||
|
procedure Paint; override;
|
||||||
published
|
published
|
||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
property FColor: TColor read fFColor write SetFColor;
|
property FColor: TColor read fFColor write SetFColor;
|
||||||
|
@@ -43,7 +43,6 @@ type
|
|||||||
procedure SetFilledSideColor2(C: TColor);
|
procedure SetFilledSideColor2(C: TColor);
|
||||||
protected
|
protected
|
||||||
{ Protected declarations }
|
{ Protected declarations }
|
||||||
procedure Paint;
|
|
||||||
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
||||||
procedure WMSize(var Msg: TMessage); message WM_SIZE;
|
procedure WMSize(var Msg: TMessage); message WM_SIZE;
|
||||||
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
||||||
@@ -52,6 +51,7 @@ type
|
|||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
constructor Create(Owner: TComponent); override;
|
constructor Create(Owner: TComponent); override;
|
||||||
|
procedure Paint; override;
|
||||||
published
|
published
|
||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
property Position: integer read FPosition write SetPos;
|
property Position: integer read FPosition write SetPos;
|
||||||
|
@@ -53,7 +53,6 @@ type
|
|||||||
procedure SetShadowColor(C: TColor);
|
procedure SetShadowColor(C: TColor);
|
||||||
protected
|
protected
|
||||||
{ Protected declarations }
|
{ Protected declarations }
|
||||||
procedure Paint;
|
|
||||||
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
procedure WMPaint(var Msg: TMessage); message WM_PAINT;
|
||||||
procedure WMSize(var Msg: TMessage); message WM_SIZE;
|
procedure WMSize(var Msg: TMessage); message WM_SIZE;
|
||||||
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
procedure WMActiv(var Msg: TMessage); message WM_SHOWWINDOW;
|
||||||
@@ -62,6 +61,7 @@ type
|
|||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
constructor Create(Owner: TComponent); override;
|
constructor Create(Owner: TComponent); override;
|
||||||
|
procedure Paint; override;
|
||||||
published
|
published
|
||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
property Position1: integer read FPosition1 write SetPos1;
|
property Position1: integer read FPosition1 write SetPos1;
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
unit tinyJPGGIFBMP;
|
unit tinyJPGGIFBMP;
|
||||||
|
|
||||||
// file: tinyJPGGIFBMP.pas
|
// file: tinyJPGGIFBMP.pas
|
||||||
// file version: 0.35
|
// file version: 0.35
|
||||||
// last modified: 05.01.06
|
// last modified: 05.01.06
|
||||||
@@ -7,44 +6,44 @@ unit tinyJPGGIFBMP;
|
|||||||
// author: Karpinskyj Alexandr aka homm
|
// author: Karpinskyj Alexandr aka homm
|
||||||
// mailto: homm86@mail.ru
|
// mailto: homm86@mail.ru
|
||||||
// My humble Web-Page: http://www.homm86.narod.ru
|
// My humble Web-Page: http://www.homm86.narod.ru
|
||||||
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, KOL, ActiveX;
|
Windows, KOL, ActiveX;
|
||||||
|
|
||||||
type
|
type
|
||||||
TBitmapmod = object( TBitMap )
|
TBitmapmod = object(TBitMap)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
IID_IPicture: TGUID = '{7BF80980-BF32-101A-8BBB-00AA00300CAB}';
|
||||||
|
|
||||||
procedure tinyLoadJPGGIFBMPFile(var TargetBitmap: PBitMap; FileName: String);
|
procedure tinyLoadJPGGIFBMPFile(var TargetBitmap: PBitMap; FileName: String);
|
||||||
procedure tinyLoadJPGGIFBMPMemory(var TargetBitmap: PBitMap; Ptr: HGlobal; Size: DWORD);
|
procedure tinyLoadJPGGIFBMPMemory(var TargetBitmap: PBitMap; Ptr: HGlobal; Size: DWORD);
|
||||||
procedure tinyLoadJPGGIFBMPResource(var TargetBitmap: PBitMap; Inst : HInst; ResName : PChar; ResType : PChar);
|
procedure tinyLoadJPGGIFBMPResource(var TargetBitmap: PBitMap; Inst : HInst; ResName : PChar; ResType : PChar);
|
||||||
|
procedure tinyLoadJPGGIFBMPString(const s: String; out TargetBitmap: PBitMap);
|
||||||
|
|
||||||
|
|
||||||
|
function SHCreateStreamOnFileA(FileName: PChar; grfMode: DWORD; var stream: IStream): HResult; stdcall; external 'shlwapi.dll';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
procedure OleFree(Picta: IPicture);
|
||||||
IID_IPicture:TGUID='{7BF80980-BF32-101A-8BBB-00AA00300CAB}';
|
|
||||||
|
|
||||||
function SHCreateStreamOnFileA(FileName: PChar; grfMode: DWORD;var stream: IStream): HResult;
|
|
||||||
external 'shlwapi.dll' name 'SHCreateStreamOnFileA';
|
|
||||||
|
|
||||||
procedure OleFree( Picta: IPicture );
|
|
||||||
{begin
|
{begin
|
||||||
if Picta <> nil then
|
if Picta <> nil then
|
||||||
Picta._Release;}
|
Picta._Release;}
|
||||||
asm
|
asm
|
||||||
push eax
|
push eax
|
||||||
mov eax, esp
|
mov eax, esp
|
||||||
call System.@IntFClear
|
call System.@IntFClear
|
||||||
pop eax
|
pop eax
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure tinyLoadJPGGIFBMPFile(var TargetBitmap: PBitMap; FileName: String);
|
procedure tinyLoadJPGGIFBMPFile(var TargetBitmap: PBitMap; FileName: String);
|
||||||
var Stream: IStream;
|
var
|
||||||
Picta: IPicture;
|
Stream: IStream;
|
||||||
hh: THandle;
|
Picta: IPicture;
|
||||||
|
hh: THandle;
|
||||||
asm
|
asm
|
||||||
//[ebx] = PBitmap;
|
//[ebx] = PBitmap;
|
||||||
//edi = FileName;
|
//edi = FileName;
|
||||||
@@ -109,34 +108,96 @@ asm
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure tinyLoadJPGGIFBMPMemory(var TargetBitmap: PBitMap; Ptr: HGlobal; Size: DWORD);
|
procedure tinyLoadJPGGIFBMPMemory(var TargetBitmap: PBitMap; Ptr: HGlobal; Size: DWORD);
|
||||||
var Stream: IStream;
|
var
|
||||||
Picta: IPicture;
|
Stream: IStream;
|
||||||
hh: THandle;
|
Picta: IPicture;
|
||||||
|
hh: THandle;
|
||||||
begin
|
begin
|
||||||
TargetBitmap := nil;
|
TargetBitmap := nil;
|
||||||
if CreateStreamOnHGlobal(ptr, TRUE, Stream) <> S_OK then
|
if CreateStreamOnHGlobal(ptr, TRUE, Stream) <> S_OK then
|
||||||
exit;
|
exit;
|
||||||
if OleLoadPicture(Stream, Size, false, IID_IPicture, Picta) <> S_OK then
|
if OleLoadPicture(Stream, Size, false, IID_IPicture, Picta) <> S_OK then
|
||||||
exit;
|
exit;
|
||||||
|
Picta.get_Handle(hh);
|
||||||
|
Picta._AddRef;
|
||||||
|
TargetBitmap := NewBitmap(0, 0);
|
||||||
|
TargetBitmap.Handle := hh;
|
||||||
|
TargetBitmap.Add2AutoFreeEx(TObjectMethod(MakeMethod(Pointer(Picta), @OleFree)));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure tinyLoadJPGGIFBMPResource(var TargetBitmap: PBitMap; Inst : HInst; ResName : PChar; ResType : PChar);
|
||||||
|
var
|
||||||
|
G: Pointer;
|
||||||
|
Sz: DWORD;
|
||||||
|
Ptr: Pointer;
|
||||||
|
Resource: HRSRC;
|
||||||
|
begin
|
||||||
|
Resource := FindResource(Inst, ResName, ResType);
|
||||||
|
Sz := SizeofResource(Inst, Resource);
|
||||||
|
DWORD(G) := LoadResource(hinstance, Resource);
|
||||||
|
DWORD(Ptr) := LocalAlloc(GMEM_FIXED, Sz);
|
||||||
|
move(g^, Ptr^, Sz);
|
||||||
|
tinyLoadJPGGIFBMPMemory(TargetBitmap, DWORD(Ptr), Sz);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure tinyLoadJPGGIFBMPString(const s: String; out TargetBitmap: PBitMap);
|
||||||
|
var
|
||||||
|
hh: DWORD;
|
||||||
|
hPtr: DWORD;
|
||||||
|
len: Integer;
|
||||||
|
Stream: IStream;
|
||||||
|
Picta: IPicture;
|
||||||
|
begin
|
||||||
|
TargetBitmap := nil;
|
||||||
|
// global
|
||||||
|
len := Length(s);
|
||||||
|
if (len > 0) then begin
|
||||||
|
hPtr := GlobalAlloc(GPTR, len);
|
||||||
|
if (hPtr <> 0) then begin
|
||||||
|
CopyMemory(Pointer(hPtr), @s[1], len);
|
||||||
|
// create istream
|
||||||
|
if (CreateStreamOnHGlobal(hPtr, False, Stream) = S_OK) then begin
|
||||||
|
// oleload
|
||||||
|
if (OleLoadPicture(Stream, len, False, IID_IPicture, Picta) = S_OK) then begin
|
||||||
|
Picta.get_Handle(hh);
|
||||||
|
Picta._AddRef;
|
||||||
|
TargetBitmap := NewBitmap(0, 0);
|
||||||
|
TargetBitmap.Handle := hh;
|
||||||
|
TargetBitmap.Add2AutoFreeEx(TObjectMethod(MakeMethod(Pointer(Picta), @OleFree)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
GlobalFree(hPtr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
(*function OleLoadPictureFile(varFileName: OleVariant; var lpdispPicture: IPictureDisp): HResult; stdcall; external 'oleaut32.dll';
|
||||||
|
function OleLoadPicturePath(szURLorPath: PWideChar; unkCaller: IUnknown; dwReserved: Integer; clrReserved: DWORD; const iid: TGUID; ppvRet: Pointer): HResult; stdcall; external 'oleaut32.dll';
|
||||||
|
|
||||||
|
procedure tinyLoadJPGGIFBMP_(const fn: String; out TargetBitmap: PBitMap);
|
||||||
|
var
|
||||||
|
hh: DWORD;
|
||||||
|
Picta: IPicture;
|
||||||
|
dispPicture: IPictureDisp;
|
||||||
|
begin
|
||||||
|
TargetBitmap := nil;
|
||||||
|
// load
|
||||||
|
{if (OleLoadPictureFile(fn, dispPicture) = S_OK) then begin
|
||||||
|
dispPicture.QueryInterface(IID_IPicture, Picta);
|
||||||
Picta.get_Handle(hh);
|
Picta.get_Handle(hh);
|
||||||
Picta._AddRef;
|
Picta._AddRef;
|
||||||
TargetBitmap := NewBitmap(0, 0);
|
TargetBitmap := NewBitmap(0, 0);
|
||||||
TargetBitmap.Handle := hh;
|
TargetBitmap.Handle := hh;
|
||||||
TargetBitmap.Add2AutoFreeEx(TObjectMethod(MakeMethod(Pointer(Picta), @OleFree)));
|
TargetBitmap.Add2AutoFreeEx(TObjectMethod(MakeMethod(Pointer(Picta), @OleFree)));
|
||||||
end;
|
end;}
|
||||||
|
if (OleLoadPicturePath(PWideChar(WideString(fn)), nil, 0, 0, IID_IPicture, @Picta) = S_OK) then begin
|
||||||
|
Picta.get_Handle(hh);
|
||||||
|
Picta._AddRef;
|
||||||
|
TargetBitmap := NewBitmap(0, 0);
|
||||||
|
TargetBitmap.Handle := hh;
|
||||||
|
TargetBitmap.Add2AutoFreeEx(TObjectMethod(MakeMethod(Pointer(Picta), @OleFree)));
|
||||||
|
end;
|
||||||
|
end;*)
|
||||||
|
|
||||||
procedure tinyLoadJPGGIFBMPResource(var TargetBitmap: PBitMap; Inst : HInst; ResName : PChar; ResType : PChar);
|
|
||||||
var G: Pointer;
|
|
||||||
Sz: DWORD;
|
|
||||||
Ptr: Pointer;
|
|
||||||
Resource: HRSRC;
|
|
||||||
begin
|
|
||||||
Resource := FindResource(Inst, ResName, ResType);
|
|
||||||
Sz := SizeofResource(Inst, Resource);
|
|
||||||
DWORD(G) := LoadResource(hinstance, Resource);
|
|
||||||
DWORD(Ptr) := LocalAlloc(GMEM_FIXED, Sz);
|
|
||||||
move(g^, Ptr^, Sz);
|
|
||||||
tinyLoadJPGGIFBMPMemory(TargetBitmap, DWORD(Ptr), Sz);
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user