zw版【转发·台湾nvp系列Delphi例程】HALCON Component Histogram
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;
type
TForm1 = class(TForm)
HWindowXCtrl1: THWindowXCtrl;
Button1: TButton;
HWindowXCtrl2: THWindowXCtrl;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
img : HImageX;
w , h : OleVariant;
mtype : OleVariant;
mode : array[0..3] of Variant;
values : OleVariant;
begin
img := CoHImageX.Create;
img.ReadImage(‘ic_pin‘);
img.GetImagePointer1(mtype, w, h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl1.HalconWindow);
mode[0] := ‘component_histogram‘;
mode[1] := HWindowXCtrl2.HHeightPixels div 2;
mode[2] := HWindowXCtrl2.HWidthPixels div 2;
mode[3] := 1;
values := VarArrayOf(mode);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, HWindowXCtrl2.HHeightPixels - 1, HWindowXCtrl2.HWidthPixels - 1);
HWindowXCtrl2.HalconWindow.SetPaint(values);
HWindowXCtrl2.HalconWindow.ClearWindow;
img.DispObj(HWindowXCtrl2.HalconWindow);
end;
end.