
26.05.2008, 19:57
|
Прохожий
|
|
Регистрация: 26.05.2008
Сообщения: 7
Репутация: 10
|
|
Вот собственно код....
Компилируется , но не полностью
Цитата:
unit UMain;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, V7MasterD7_TLB, StdVcl, AddInObj, Windows, Messages,
AddInLib, ComCtrls, Gauges,Variants, Classes, Graphics,
Controls, SysUtils,Dialogs, StdCtrls, ExtCtrls;
type
TMain = class(TAutoObject, IMain)
protected
function h1C: Integer; safecall;
procedure LoadBitmap(AFileName : String); safecall;
procedure FreeBitmap; safecall;
procedure DrawCircle(X, Y, R : Integer); safecall;
procedure SaveBitmapPart(X,Y,W,H : Integer; AFileName : String); safecall;
end;
implementation
uses ComServ;
var
Image : TBitmap;
function TMain.h1C: Integer;
var wnd:hwnd;
begin
_pExtWndsSupport._AddRef;
_pExtWndsSupport.GetAppMainFrame(wnd);
RESULT:=wnd;
end;
procedure TMain.LoadBitmap(AFileName : String);
begin
If Not Assigned(Image) Then Image := TBitmap.Create;
Try
Image.LoadFromFile(AFileName);
Except
FreeAndNil(Image);
Raise;
End;
end;
procedure TMain.FreeBitmap;
begin
If Assigned(Image) Then FreeAndNil(Image);
end;
procedure TMain.DrawCircle(X, Y, R : Integer);
begin
If Not Assigned(Image) Then
Raise Exception.Create('Image doesn''t loaded.');
Image.Canvas.Ellipse(Rect(X-R,Y-R,X+R,Y+R));
end;
procedure TMain.SaveBitmapPart(X,Y,W,H : Integer; AFileName : String);
var
Buf : TBitmap;
begin
Buf := TBitmap.Create;
Try
Buf.PixelFormat := pf24Bit;
Buf.Width := W;
Buf.Height := H;
Buf.Canvas.CopyRect(Rect(0,0,W,H),Image.Canvas,Rec t(x,y,x+W,y+W));
Buf.SaveToFile(AFileName);
Finally
Buf.Free;
End;
end;
initialization
TAutoObjectFactory.Create(ComServer, TMain, Class_Main,
ciMultiInstance, tmApartment);
end.
|
|