码迷,mamicode.com
首页 > Windows程序 > 详细

zw版【转发·台湾nvp系列Delphi例程】HALCON SetWindowExtent

时间:2015-10-01 16:29:31      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

zw版【转发·台湾nvp系列Delphi例程】HALCON SetWindowExtent

技术分享

 

技术分享

 

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, HALCONXLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
HWindowXCtrl1: THWindowXCtrl;
Button2: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
win : HWindowX;
img : HImageX;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
win := HWindowXCtrl1.HalconWindow;
img := CoHImageX.Create;
img.ReadImage(‘ic1‘);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
w, h : OleVariant;
c, w0, h0 : Integer;
dr, dc : Integer;
begin
w := img.GetImageSize(h);
win.GetWindowExtents(c, w0, h0);
dr := (Integer(h) - h0) div 2;
dc := (Integer(w) - w0) div 2;
win.ClearWindow;
win.SetPart(dr, dc, h0 + dr, w0 + dc);
img.DispObj(win);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
w, h : OleVariant;
begin
w := img.GetImageSize(h);
win.SetWindowExtents(0, 0, HWindowXCtrl1.HWidthPixels, HWindowXCtrl1.HHeightPixels);
win.ClearWindow;
win.SetPart(0, 0, h - 1, w - 1);
img.DispObj(win);
end;
end.

 

zw版【转发·台湾nvp系列Delphi例程】HALCON SetWindowExtent

标签:

原文地址:http://www.cnblogs.com/ziwang/p/4851032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!