请问怎样以二进制的方式打开任何文件!
解决方案 »
- 希望大家能帮帮我,跪求,怎样来实现服务器传文件给多台客户端,我用的是Tidtcpservert和tidtcpclient控件
- 怎樣把表中的字段名加到combobox中?
- 一个dll问题求助!
- udpsocket,在线等!
- 各位高手,看看这条SQL语句???
- 江湖告急!!!关于ActiveX控件
- 将query的数据倒入excel该如何处理
- 请问如何在DELPHI中运行外部的EXE程序?
- 简单问题,TQuery.Filted和Lookup那个更快?
- 此查询为何出现错误,出现非法的字段?(我现在急于知道这个答案)
- 如何在QuickReport中的TQRDBText自动换行(很急的)
- 控件事件赋值的问题
procedure AddJpeg(bitmap:TBitmap;var JPGFileName:string);
var
jpgfile:TFileStream;
buffer:^byte;
i,j,filesize:integer;
P:pbytearray;
temp:Longint;
begin
if jpgfilename='' then exit;
try
jpgfile := TFileStream.Create(jpgFileName,fmOpenRead);
except
jpgfile.Free;
end;
try
i:=1;
j:=0;
buffer:=AllocMem(1);
p:=bitmap.ScanLine[0];
filesize:= jpgfile.Size ;
temp:=floor(bitmap.Width*3/4)-3;
while i<=filesize do
begin
jpgfile.Read(buffer^,1);
if (i mod temp)=0 then
begin
inc(j);
if j<=Bitmap.Height-1 then
begin
p[4*((i mod temp)-1)] :=(p[4*((i mod temp)-1)] and $FC) +((buffer^ and $C0) shr 6); //将前2位保存在R的后2位上
p[4*((i mod temp)-1)+1]:=(p[4*((i mod temp)-1)+1] and $FC)+((buffer^ and $30) shr 4);//将3,4位保存在G的后3,4位上
p[4*((i mod temp)-1)+2]:=(p[4*((i mod temp)-1)+2] and $FC)+((buffer^ and $0C) shr 2);//将5,6位保存在G的后5,6位上
p[4*((i mod temp)-1)+3]:=(p[4*((i mod temp)-1)+3] and $FC)+((buffer^ and $03));//将7,8位保存在G的后7,8位上
p:=Bitmap.ScanLine[j];
end;
end else
begin
p[4*((i mod temp)-1)] :=(p[4*((i mod temp)-1)] and $FC) +((buffer^ and $C0) shr 6); //将前2位保存在R的后2位上
p[4*((i mod temp)-1)+1]:=(p[4*((i mod temp)-1)+1] and $FC)+((buffer^ and $30) shr 4);//将3,4位保存在G的后3,4位上
p[4*((i mod temp)-1)+2]:=(p[4*((i mod temp)-1)+2] and $FC)+((buffer^ and $0C) shr 2);//将5,6位保存在G的后5,6位上
p[4*((i mod temp)-1)+3]:=(p[4*((i mod temp)-1)+3] and $FC)+((buffer^ and $03));//将7,8位保存在G的后7,8位上
end;
inc(i);
jpgfile.Seek(0,1);
end;
finally
jpgfile.Free;
freemem(buffer);
end;
bitmap.Canvas.Pixels[bitmap.Width-1,bitmap.Height-1]:=filesize xor $FFFFFF;
end;
var
F: File of Byte;
ch: Byte;
begin
AssignFile(F,'C:\aa.dat');
Reset(F);
while not eof(F) do
begin
read(F,ch); //然后作你的处理,要读一块的话用BlockRead
end;
CloseFIle(F);
end;