zhq445078388 发表于 2011-8-11 11:04
没错没错。。
就是那效果。。所以。。现在这个版本有自适应了
但是 点太少。。还是容易误报
Delphi版本- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls,ImagingTypes, Imaging,jpeg, ExtCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Image1: TImage;
- OpenDialog1: TOpenDialog;
- Button2: TButton;
- Edit1: TEdit;
- ListBox1: TListBox;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure ListBox1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- PdWordArray = ^TdWordArray;
- TdWordArray = array[0..16383] of dWORD;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- Img: TImageData;
- imgstream:TMemoryStream;
- b1:Byte;
- b2:Byte;
- x,y,xx,yy,i,yi:Integer;
- ig:TMemoryStream;
- jpg:tjpegimage;
- gs:array[0..256] of Integer;
- begin
- if not OpenDialog1.Execute then Exit;
- InitImage(img);
- NewImage(1024,1024,ifGray8,img);
- imgstream:=TMemoryStream.Create ;
- ig:=TMemoryStream.Create ;
- imgstream.LoadFromFile(OpenDialog1.FileName);
- imgstream.Position:=32;
- imgstream.Read(gs[0],1028);
- //ShowMessage(IntToStr(i));
- yi:=StrToInt(Edit1.Text);
- for i := 0 to 255 do
- begin
- imgstream.Position:=1060+gs[i]*8192;
- if gs[i]<>-1 then
- begin
- for y := 0 to 63 do
- begin
- yy:=(i div 16)*64 +y;
- for x := 0 to 63 do
- begin
- xx:=(i-(i div 16) *16)*64 +x;
- //xx:= xxx*64 + x;
- imgstream.Read(b1,1);imgstream.Read(b2,1);
- b1:=(b2 shr yi) and yi;
- //PdWordArray(@PdWordArray(Img.Bits)[(1023-yy) * 1024])[xx] :=b1*100;
- PByteArray(@PByteArray(Img.Bits)[yy * 1024])[xx] :=b1*255;
- // imgstream.Read(b1,1);
- end;
- end;
- end;
- end;
- SaveImageToFile('dhmap.jpg',img);
- jpg:= tjpegimage.Create ;
- ig.SetSize(0);
- SaveImageToStream('jpg',ig,img);
- ig.Position:=0;
- jpg.LoadFromStream(ig);
- Image1.Picture.Assign(jpg);
- jpg.Free;
- FreeImage(img);
- ig.Free;
- imgstream.Free;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var
- Img: TImageData;
- imgstream:TMemoryStream;
- b1,b2:Byte;
- x,y,xx,yy,i:Integer;
- ig:TMemoryStream;
- jpg:tjpegimage;
- gs:array[0..256] of Integer;
- begin
- if not OpenDialog1.Execute then Exit;
- InitImage(img);
- NewImage(1024,1024,ifGray8,img);
- imgstream:=TMemoryStream.Create ;
- ig:=TMemoryStream.Create ;
- imgstream.LoadFromFile(OpenDialog1.FileName);
- imgstream.Position:=32;
- imgstream.Read(gs[0],1028);
- //ShowMessage(IntToStr(i));
- for i := 0 to 255 do
- begin
- imgstream.Position:=1060+gs[i]*8192;
- if gs[i]<>-1 then
- begin
- for y := 0 to 63 do
- begin
- yy:=(i div 16)*64 +y;
- for x := 0 to 63 do
- begin
- xx:=(i-(i div 16) *16)*64 +x;
- //xx:= xxx*64 + x;
- imgstream.Read(b1,1); imgstream.Read(b2,1);
- PByteArray(@PByteArray(Img.Bits)[(1023-yy) * 1024])[xx] :=b1;
- //PByteArray(@PByteArray(Img.Bits)[yy * 1024])[xx] :=b2*10;
- // imgstream.Read(b1,1);
- end;
- end;
- end;
- end;
- SaveImageToFile('dhmap.jpg',img);
- jpg:= tjpegimage.Create ;
- ig.SetSize(0);
- SaveImageToStream('jpg',ig,img);
- ig.Position:=0;
- jpg.LoadFromStream(ig);
- Image1.Picture.Assign(jpg);
- jpg.Free;
- FreeImage(img);
- ig.Free;
- imgstream.Free;
- end;
- procedure TForm1.ListBox1Click(Sender: TObject);
- var
- Img: TImageData;
- imgstream:TMemoryStream;
- b1:Word;
- b2:Byte;
- x,y,xx,yy,i,yi:Integer;
- ig:TMemoryStream;
- jpg:tjpegimage;
- gs:array[0..256] of Integer;
- begin
- if OpenDialog1.FileName='' then Exit;
- InitImage(img);
- NewImage(1024,1024,ifGray8,img);
- imgstream:=TMemoryStream.Create ;
- ig:=TMemoryStream.Create ;
- imgstream.LoadFromFile(OpenDialog1.FileName);
- imgstream.Position:=32;
- imgstream.Read(gs[0],1028);
- //ShowMessage(IntToStr(i));
- yi:=StrToInt(Edit1.Text);
- for i := 0 to 255 do
- begin
- imgstream.Position:=1060+gs[i]*8192;
- if gs[i]<>-1 then
- begin
- for y := 0 to 63 do
- begin
- yy:=(i div 16)*64 +y;
- for x := 0 to 63 do
- begin
- xx:=(i-(i div 16) *16)*64 +x;
- //xx:= xxx*64 + x;
- imgstream.Read(b1,2);//imgstream.Read(b2,1);
- b1:=(b1 shr ListBox1.ItemIndex) and yi;
- //PdWordArray(@PdWordArray(Img.Bits)[(1023-yy) * 1024])[xx] :=b1*100;
- PByteArray(@PByteArray(Img.Bits)[yy * 1024])[xx] :=b1*255;
- // imgstream.Read(b1,1);
- end;
- end;
- end;
- end;
- SaveImageToFile('dhmap.jpg',img);
- jpg:= tjpegimage.Create ;
- ig.SetSize(0);
- SaveImageToStream('jpg',ig,img);
- ig.Position:=0;
- jpg.LoadFromStream(ig);
- Image1.Picture.Assign(jpg);
- jpg.Free;
- FreeImage(img);
- ig.Free;
- imgstream.Free;
- end;
- end.
复制代码 |