📄 showdv.~pas
字号:
unit ShowDV;
interface
uses
DataUnit,Classes,windows,Graphics;
type
TShowToDevice = class(TThread)
private
{ Private declarations }
Index:Integer;
First:Boolean;
ScrBitmap: TBitmap;
Scr: Pointer;
SX, SY: Integer;
MyHandle:Integer;
Error:String;
protected
DataSend:array[0..$1000] of TDevicePoints;
procedure Execute; override;
Procedure ShowImage;
Procedure Processing;
procedure DeleteBitmap;
procedure CreateBitmap(aSX, aSY: Integer);
procedure DrawFrame;
end;
implementation
uses Unit1,Sysutils,output{,settings};
procedure pause(x:integer);
var ui:longint;b:byte;
begin
for ui:=1 to x*10000 do b:=b+0;
end;
procedure TShowToDevice.DeleteBitmap;
begin
ScrBitmap.FreeImage();
ScrBitmap.Destroy;
end;
procedure TShowToDevice.CreateBitmap(aSX, aSY: Integer);
var
BInfo: tagBITMAPINFO;
begin
SX := aSX; SY := aSY;
ScrBitmap := TBitmap.Create();
ScrBitmap.PixelFormat:=pf8bit;
ScrBitmap.Width:=SX;
ScrBitmap.Height:=SY;
end;
Procedure TShowToDevice.DrawFrame;
Var
sp,ax,ay,xx,yy,I:Integer;
TotalTime:Int64;
Begin
With ScrBitmap.Canvas do
Begin
Pen.Color:=ClBlack;
Brush.Color:=ClBlack;
Rectangle(0,0,Form1.MyWidth,Form1.MyHeight);
Pen.Color:=Rgb(IldaColorTable[MyShow.Frames[Index].Points[0].Color,0],
IldaColorTable[MyShow.Frames[Index].Points[0].Color,1],
IldaColorTable[MyShow.Frames[Index].Points[0].Color,2]);
MoveTo(Round((MyShow.Frames[Index].Points[0].X)*(Form1.MyPolWidth/2048)),
(Round((MyShow.Frames[Index].Points[0].Y)*(Form1.MyPolHeight/2048))));
// sd(255-Round((MyShow.Frames[Index].Points[0].y)*(Form1.MyPolWidth/2048)),
// 255-Round((MyShow.Frames[Index].Points[0].x)*(Form1.MyPolHeight/2048)));
// sdrgb(1);
For i:=1 To MyShow.Frames[Index].CountPoints-1 do
Begin
form1.scanspeed:=form1.scanspeed+1;
Pen.Color:=Rgb(IldaColorTable[MyShow.Frames[Index].Points[i].Color,0],
IldaColorTable[MyShow.Frames[Index].Points[i].Color,1],
IldaColorTable[MyShow.Frames[Index].Points[i].Color,2]);
form1.portr:=IldaColorTable[MyShow.Frames[Index].Points[i].Color,0];
form1.portg:=IldaColorTable[MyShow.Frames[Index].Points[i].Color,1];
form1.portb:=IldaColorTable[MyShow.Frames[Index].Points[i].Color,2];
form1.portrgb:=1;
if (form1.portR=0) and (form1.portg=0) and (form1.portb=0) then form1.portrgb:=1;
if form1.portR>127 then form1.portrgb:=2; //red
if form1.portg>127 then form1.portrgb:=4; //green
if form1.portb>127 then form1.portrgb:=8; //blue
if (form1.portg>127) and (form1.portb>127) then form1.portrgb:=12; //aqua
if (form1.portr>127) and (form1.portg>127) then form1.portrgb:=6; //yellow
if (form1.portr>127) and (form1.portb>127) then form1.portrgb:=12; //purple
if (form1.portb>127) and (form1.portg>127) and (form1.portR>127) then form1.portrgb:=14;
xx:=Round((MyShow.Frames[Index].Points[i].X)*(Form1.MyPolWidth/2048));
yy:=Round((MyShow.Frames[Index].Points[i].Y)*(Form1.MyPolHeight/2048));
xx:=round(xx/1.6);
yy:=round(yy/1.6);
if xx<128 then xx:=round(xx+((128-xx)*((100-form1.scrollbar3.position)/100)))
else xx:=round(xx-((xx-128)*((100-form1.scrollbar3.position)/100)));
if yy<128 then yy:=round(yy+((128-yy)*((100-form1.scrollbar3.position)/100)))
else yy:=round(yy-((yy-128)*((100-form1.scrollbar3.position)/100)));
if xx>255 then xx:=255;
if xx<0 then xx:=0;
if yy>255 then yy:=255;
if yy<0 then yy:=0;
if MyShow.Frames[Index].Points[i].I=0 Then
begin
MoveTo(round(1.6*xx),round(1.6*yy));
if form1.checkbox2.Checked then xx:=255-xx;
if form1.checkbox3.Checked then yy:=255-yy;
if form1.checkbox4.Checked then
begin
ax:=xx;
ay:=yy;
xx:=ay;
yy:=ax;
end;
// sdrgb(1);
// sd(255-yy,255-xx);
pause(form1.scrollbar2.position*2);
// form1.memo1.Lines.Add('0 x='+inttostr(xx)+'y='+inttostr(yy));
end
Else
begin
lineTo(round(1.6*xx),round(1.6*yy));
if form1.checkbox2.Checked then xx:=255-xx;
if form1.checkbox3.Checked then yy:=255-yy;
if form1.checkbox4.Checked then
begin
ax:=xx;
ay:=yy;
xx:=ay;
yy:=ax;
end;
// sd(255-yy,255-xx);
// sdrgb(form1.portrgb);
pause(form1.scrollbar2.position);
// sleep(form1.spinedit3.value);
// form1.memo1.Lines.Add('0 x='+inttostr(xx)+'y='+inttostr(yy));
end;
if Show_points_frame Then
Ellipse(Round((MyShow.Frames[Index].Points[i].X)*(Form1.MyPolWidth/2048))-3,(Round((MyShow.Frames[Index].Points[i].Y)*(Form1.MyPolHeight/2048)))-3,
Round((MyShow.Frames[Index].Points[i].X)*(Form1.MyPolWidth/2048))+3,(Round((MyShow.Frames[Index].Points[i].Y)*(Form1.MyPolHeight/2048)))+3);
End;
Brush.Style:=bsClear;
Font.Color:=ClWhite;
TextOut(0,0,ShowFileName);
TextOut(0,Form1.MyHeight-30,'Frame '+IntTOStr(Index)+' from '+IntTOStr(MyShow.CountFrame));
TextOut(0,Form1.MyHeight-15,'points '+IntTOStr(MyShow.Frames[Index].CountPoints));
// TotalTime:=(MyShow.CountPoints*Form2.VrNum1.Value) div 10000;
TextOut(Form1.MyWidth-115,Form1.MyHeight-30,'Scan Speed '+form1.Panel3.Caption+' pps');
TextOut(Form1.MyWidth-115,Form1.MyHeight-15,'Speed Frames '+form1.Panel4.Caption+' fps');
// TextOut(Form1.MyWidth-100,Form1.MyHeight-15,'Total time '+IntTOStr((TotalTime div 100) div 60)+':'+IntTOStr((TotalTime div 100) mod 60)+','+IntToStr(TotalTime mod 100));
// TextOut(Form1.MyWidth-120,Form1.MyHeight-30,'Current time '+TimeToStr(Now-Form1.StartTime));
// TextOut(Form1.MyWidth-250,Form1.MyHeight-15,'Scanrate '+IntToStr(Form2.VrNum2.Value)+'PPS');
TextOut(Form1.MyWidth-100,15,'Palette:'+PalleteTxt);
Brush.Style:=bsSolid;
End;
End;
Procedure TShowToDevice.ShowImage;
Begin
Form1.Image1.Canvas.Draw(0, 0, ScrBitmap);
End;
Procedure TShowToDevice.Processing;
Var
i:Integer;
Hide:Boolean;
PromX,PromY:Short;
Begin
if MyShow.CountFrame<=Index Then
Begin
Index:=0;
First:=False;
End;
For i:=0 to MyShow.Frames[Index].CountPoints-1 do
Begin
Hide:=False;
DataSend[i].X:=2048+Round((MyShow.Frames[Index].Points[i].X-2048)*MultAixY[0]-(MyShow.Frames[Index].Points[i].Y-2048)*MultAixX[0]);
DataSend[i].Y:=2048+Round((MyShow.Frames[Index].Points[i].Y-2048)*MultAixY[0]+(MyShow.Frames[Index].Points[i].X-2048)*MultAixX[0]);
if DataSend[i].X>4096 Then DataSend[i].X:=4095;
if DataSend[i].Y>4096 Then DataSend[i].Y:=4095;
if DataSend[i].X<0 Then DataSend[i].X:=0;
if DataSend[i].Y<0 Then DataSend[i].Y:=0;
PromX:=2048+Round((DataSend[i].X-2048)+SumAixX[DataSend[i].X]*(2048-DataSend[i].Y));
PromY:=2048+Round((DataSend[i].Y-2048)+SumAixY[DataSend[i].Y]*(2048-DataSend[i].X));
DataSend[i].X:=PromX;
DataSend[i].Y:=PromY;
if DataSend[i].X>4096 Then DataSend[i].X:=4095;
if DataSend[i].Y>4096 Then DataSend[i].Y:=4095;
if DataSend[i].X<0 Then DataSend[i].X:=0;
if DataSend[i].Y<0 Then DataSend[i].Y:=0;
if DataSend[i].X<2048 Then PromX:=2048+Round((DataSend[i].X-2048)+((KeyStone_X)*(2048-DataSend[i].Y)*ABS(DataSend[i].X-2048)/2048))
Else PromX:=2048+Round((DataSend[i].X-2048)-((KeyStone_X)*(2048-DataSend[i].Y)*ABS(DataSend[i].X-2048)/2048));
if DataSend[i].Y<2048 Then PromY:=2048+Round((DataSend[i].Y-2048)+((KeyStone_Y)*(2048-DataSend[i].X)*ABS(DataSend[i].Y-2048)/2048))
Else PromY:=2048+Round((DataSend[i].Y-2048)-((KeyStone_Y)*(2048-DataSend[i].X)*ABS(DataSend[i].Y-2048)/2048));
DataSend[i].X:=PromX;
DataSend[i].Y:=PromY;
if DataSend[i].X>4096 Then DataSend[i].X:=4095;
if DataSend[i].Y>4096 Then DataSend[i].Y:=4095;
if DataSend[i].X<0 Then DataSend[i].X:=0;
if DataSend[i].Y<0 Then DataSend[i].Y:=0;
DataSend[i].X:=ShiftX+ABS((2048+(Round((DataSend[i].X-2048)*ScaleX)))-Mirr_X);
DataSend[i].Y:=ShiftY+ABS((2048+(Round((DataSend[i].Y-2048)*ScaleY)))-Mirr_Y);
if DataSend[i].X<0 Then
Begin
DataSend[i].X:=0;
Hide:=true;
End;
if DataSend[i].Y<0 Then
Begin
DataSend[i].Y:=0;
Hide:=true;
End;
if DataSend[i].X>4096 Then
Begin
DataSend[i].X:=4095;
Hide:=true;
End;
if DataSend[i].Y>4096 Then
Begin
DataSend[i].Y:=4095;
Hide:=true;
End;
if (First) and (Index=0) and (i<=DelayColor) and (DelayColor<>0) Then
Begin
Hide:=True;
End;
if Hide Then
Begin
DataSend[i].Color:=HidePoint;
DataSend[i].i:=0;
End
Else
Begin
if (Index=0) and (i<=DelayColor) Then
Begin
DataSend[i].Color:=TMyColor(IldaColorTable[MyShow.Frames[MyShow.CountFrame-1].Points[(MyShow.Frames[MyShow.CountFrame-1].CountPoints-1)+i-DelayColor].Color]);
DataSend[i].i:=MyShow.Frames[MyShow.CountFrame-1].Points[(MyShow.Frames[MyShow.CountFrame-1].CountPoints-1)+i-DelayColor].i;
End
Else
if (i<=DelayColor) Then
Begin
DataSend[i].Color:=TMyColor(IldaColorTable[MyShow.Frames[Index-1].Points[(MyShow.Frames[index-1].CountPoints-1)+i-DelayColor].Color]);
DataSend[i].i:=MyShow.Frames[Index-1].Points[(MyShow.Frames[index-1].CountPoints-1)+i-DelayColor].i;
End
Else
Begin
DataSend[i].Color:=TMyColor(IldaColorTable[MyShow.Frames[Index].Points[i-DelayColor].Color]);
DataSend[i].i:=MyShow.Frames[Index].Points[i-DelayColor].i;
End;
End
End;
End;
procedure TShowToDevice.Execute;
Var
rep:byte;
Attribute:Byte;
IntDv:Byte;
begin
{ Place thread code here }
//MyHandle:=Form1.Image1.Canvas.Handle;
//CreateBitmap(343,279);
Index:=0;
Attribute:=16;
First:=True;
Processing;
form1.scanspeed:=0;
repeat
Index:=Index+1;
Processing;
for rep:=1 to form1.scrollbar1.position do //round(500/MyShow.Frames[Index].CountPoints*form1.scrollbar1.position) do
begin
form1.nrpoint:=MyShow.Frames[Index].CountPoints;
form1.framesspeed:=form1.framesspeed+1;
MyHandle:=Form1.Image1.Canvas.Handle;
CreateBitmap(408,408);
DrawFrame;
Synchronize(ShowImage);
DeleteBitmap;
end;
until Terminated;
index:=0;
form1.framesspeed:=0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -