读取JPG图片的内容时就是二进制代码如下: 文件名:T0000001.jpg 内容: 諷q\罃$凅??(?QLAEPEP6胥o \座T?燑x? ?59n%癚E?QE QE QE QE QE QE QE Cg6 跬昅P? 菎魁s_錝S栤[筠﹚4z荆?c?d宅e韅鉨闏0?崶c峊?臑p峻C羛M碚雵姆W"W燑x? ?5Cg 6 跬昅N[塴g揲Iu,?\Ocz?~譵穨懒€!諔皊嵤v飣杠s&摟Ch?e?Ago糾!姠???J笶!卻鄊?韹s霁媮皋4蜽K篍葀 ?L堵呬/友@繇:.莪瓩虐ra厛+鄚壠B?诬郺B⊕势螹硯衣?[h蟛#嫆I聨I'瘾PY疰扞&讚 M黨>見??兲癍J+楆Xmw|懴鮈?_r(Z韬}滊=骄?8;仵鷼縀?Pすi?洮k //============================================= 内容就这些东西
var f:TMemoryStream; s:string; begin f:= TMemoryStream.Create; f.LoadFromFile('c:\my.ini'); setlength(s,f.size); f.Read(s[1],f.size); f.Free; showmessage(s);
'c:\my.ini' 换成你的图片文件名及路径
那写入的方法是不是 var PicMemoryStream : TMemoryStream; Picstr:string; //初始化字符串 begin if image1.Picture<>nil then begin //Picstr:=Image1 PicMemoryStream := TMemoryStream.Create; Image1.Picture.Graphic.SaveToStream(PicMemoryStream); PicMemoryStream.Position := 0; //inttostr((image1.Left)*(image1.Height)) //文件大小 PicMemoryStream.SaveToFile('..\output.dat');//标识文件的大小 PicMemoryStream.Free; end;
文件名:T0000001.jpg
内容:
諷q\罃$凅??(?QLAEPEP6胥o \座T?燑x? ?59n%癚E?QE QE QE QE QE QE QE Cg6 跬昅P? 菎魁s_錝S栤[筠﹚4z荆?c?d宅e韅鉨闏0?崶c峊?臑p峻C羛M碚雵姆W"W燑x? ?5Cg 6 跬昅N[塴g揲Iu,?\Ocz?~譵穨懒€!諔皊嵤v飣杠s&摟Ch?e?Ago糾!姠???J笶!卻鄊?韹s霁媮皋4蜽K篍葀 ?L堵呬/友@繇:.莪瓩虐ra厛+鄚壠B?诬郺B⊕势螹硯衣?[h蟛#嫆I聨I'瘾PY疰扞&讚 M黨>見??兲癍J+楆Xmw|懴鮈?_r(Z韬}滊=骄?8;仵鷼縀?Pすi?洮k
//=============================================
内容就这些东西
var
f:TMemoryStream;
s:string;
begin
f:= TMemoryStream.Create;
f.LoadFromFile('c:\my.ini');
setlength(s,f.size);
f.Read(s[1],f.size);
f.Free;
showmessage(s);
var
PicMemoryStream : TMemoryStream;
Picstr:string; //初始化字符串
begin
if image1.Picture<>nil then
begin
//Picstr:=Image1
PicMemoryStream := TMemoryStream.Create;
Image1.Picture.Graphic.SaveToStream(PicMemoryStream);
PicMemoryStream.Position := 0;
//inttostr((image1.Left)*(image1.Height)) //文件大小
PicMemoryStream.SaveToFile('..\output.dat');//标识文件的大小
PicMemoryStream.Free;
end;
j.LoadFromStream("jpg文件内存");
Image1.Picture.Assign(j);
再保存到dat文件,因为这样的话文件就是上面信息的标识符,
以方便读取时也能分离出图片和文件名,并做出相应的显示处理.........
文件为有规则的 文件名8位====扩展名3位即如下:
A0000001.JPG
A0000002.JPG
A0000003.JPG
A0000004.JPG
A0000005.JPG
A0000006.JPG
内容格式是:
[文件名+长度+内容]
[A0000001.JPG+56+sdfsdfsd]
[A0000002.JPG+53+345423423]
[A0000003.JPG+22+76876864567]
[A0000004.JPG+23+67867867]
[A0000005.JPG+12+56y56756765]
[A0000006.JPG+78+5675675656765]