有哪个高手来看看我的问题出在哪,谢谢(100)

  • 主题发起人 主题发起人 zhuhaifeng20
  • 开始时间 开始时间
Z

zhuhaifeng20

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,math, ExtCtrls;type TForm1 = class(TForm) Button1: TButton; OpenDialog1: TOpenDialog; Image1: TImage; procedure Button1Click(Sender: TObject); function zuobiao(x:integer;y:integer;a:real):tpoint; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm} var fhandle:integer; procedure TForm1.Button1Click(Sender: TObject);var cb:Tpoint; dx,dy:longint; ca:real; i,j,k:integer; bfType,biPlanes,biBitCount:integer; bfSize,biSize,biWidth,biHeight,biCompress,biSizeImage,biXPelsPerMeter, biYPelsPerMeter,biClrUsed,biClrImprotant:longint; mystream:TStream; mybyte:Byte;beginif OpenDialog1.Execute then fhandle:=FileOpen(OpenDialog1.FileName,0); FileRead(fhandle,bfType,2); FileRead(fhandle,bfSize,4); FileSeek(fhandle,8,1); FileRead(fhandle,biSize,4); FileRead(fhandle,biWidth,4); FileRead(fhandle,biHeight,4); FileRead(fhandle,biPlanes,2); FileRead(fhandle,biBitCount,2); FileRead(fhandle,biCompress,4); FileRead(fhandle,biSizeImage,4); FileRead(fhandle,biXPelsPerMeter,4); FileRead(fhandle,biYPelsPerMeter,4); FileRead(fhandle,biClrUsed,4); FileRead(fhandle,biClrImprotant,4); FileSeek(fhandle,8,1); FileClose(fhandle); mystream:=TMemoryStream.Create; TMemoryStream(mystream).LoadFromFile(Opendialog1.FileName); ca:=10*pi/180; for j:=1023 downto 0 do for i:=0 to 127 do begin mystream.Read(mybyte,1); for k:=0 to 7 do begin case k of 0:begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (mybyte and 128) =128 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 1:begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 64) =64 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 2:begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (Mybyte and 32) =32 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 3:begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 16) =16 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 4: begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 8) =8 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 5: begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 4) =4 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 6:begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 2) =2 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; 7: begin cb:=zuobiao(i*8+k,1023-j,ca); dx:=cb.X; dy:=1023-cb.Y; if (MyByte and 1) =1 then image1.Canvas.Pixels[dx,dy]:=clWhite else image1.Canvas.Pixels[dx,dy]:=clBlack; end; end; end; end; end;function TForm1.zuobiao(x, y: integer; a: real): tpoint;//梯形函数var a1,a2,a3,a4:integer; b1,b2,b3,b4:integer; c:real; b:real;begin b:=20*pi/180; if (x<511.5)and(y<511.5) then begin c:=((511.5-y)/511.5)*20*pi/180; a4:=round(1023/2-cos(a+c)*cos(b)*(1023/2-x)/(cos(a-b)*cos(c))); b4:=round(y+(1023-y)*(1-cos(a+c)/cos(c))); zuobiao.X:=a4; zuobiao.Y:=b4; end; if (x>511.5)and(y<511.5) then begin c:=((511.5-y)/511.5)*20*pi/180; a3:=round(1023/2+cos(a+c)*cos(b)*(x-1023/2)/(cos(a-b)*cos(c))); b3:=round(y+(1023-y)*(1-cos(a+c)/cos(c))); zuobiao.X:=a3; zuobiao.Y:=b3; end; if (x<511.5)and(y>511.5)then begin c:=((y-511.5)/511.5)*20*pi/180; a2:=round(1023/2-cos(a-c)*cos(b)*(1023/2-x)/(cos(a-b)*cos(c))); b2:=round(y+(1023-y)*(1-cos(a-c)/cos(c))); zuobiao.X:=a2; zuobiao.Y:=b2; end; if (x>511.5)and(y>511.5)then begin c:=((y-511.5)/511.5)*20*pi/180; a1:=round(1023/2+cos(a-c)*cos(b)*(x-1023/2)/(cos(a-b)*cos(c))); b1:=round(y+(1023-y)*(1-cos(a-c)/cos(c))); zuobiao.X:=a1; zuobiao.Y:=b1; end;end;end.这是我读取1024*1024像素的单色bmp图的程序,但我读出来的程序向左或向右平移了一段距离,谁帮我看看,谢谢
 
谁来接分啊,我知道怎么做了
 
搞笑,我2个送分贴,怎么都是你们2个来接的啊。。。。[?]
 
http://m.thebei.cn/2_24_670639.aspx
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
638
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部