关于图片数据转成还原成图片的问题(80)

  • 主题发起人 主题发起人 liujiaqi
  • 开始时间 开始时间
L

liujiaqi

Unregistered / Unconfirmed
GUEST, unregistred user!
424DCE970000000000003600000028000000660000007E000000010018000000000000000000000000000000000000000000000000001B16141C18131E1A151F1B16211D181F1B161E1A151D19141C18131A19131A19131A19131A19131918111918111817101817101A19121C1B1435342D4F4E4853524C5756505B5A54605F5956554F4D4C4634332D1C1B151A191319181217161015140E11110E0F0F0E0C0D0C0A0B0A0B0E0D0D1312070F0E030B0B050D0F071115041015040E180D19241724311422311320331423351726381C2E3F2236472237482338492139492139491C313F1829361A28321C2630181E2714181E1110160C090F0F0C121310160E0B1109060C0B080E0D0A100F0C12110E141311141615161817181B1A1B1C1B1B1D1C1B1E1E1B1F1F1C31322C44453F4F504A5B5C5655565050514B4B4C464847413E3D3737332E918D882B2722332F293B373136322C342E28352F2936302A37312B38322C38322C00001B16141C18131E1A151F1B16211D181F1B161E1A151D19141C18131A19131A19131A19131A19131918111918111817101817101A19121C1B1435342D4F4E4853524C5756505B5A54605F5956554F4D4C4634332D1C1B151A191319181217161015140E11110E0F0F0E0C0D0C0A0B0A0B0E0D0D1312070F0E030B0B050D0F071115041015040E180D19241724312432413340534453655766786C7E8F8296A78297A88499AA7991A17189995C717F48596632404A1C2630181E2714181E1110160C090F0F0C121310160E0B1109060C0B080E0D0A100F0C12110E141311141615161817181B1A1B1C1B1B1D1C1B1E1E1B1F1F1C31322C44453F4F504A5B5C5655565050514B4B4C464847413E3D3737332E918D882B2722332F293B373136322C342E28352F2936302A37312B38322C38322C0000我现在有一些上面的数据是用下面的函数生成出来的function GetPhotoStr() :String;var B: TStream; I: Integer; C: Byte; D: string; sStr :WideString;begin B := TMemoryStream.Create; try TMemoryStream(B).LoadFromFile(GetCurrentDir + '/photo.bmp'); sStr := ''; B.Position := 0; for i := 1 to B.Size do begin B.Read(C, 1); D := IntToHex(C, 2); sStr := sStr + D; end; Result := sStr; finally B.Free; end;end;现在我要写一个Demo将那串图片数据还原成图片, 搞了一天一直没有头续, 请大家帮帮忙
 
...procedure StrToBmp(AStr:string;Bmp:TBitmap);var MS:TMemoryStream; bData:PChar; iSize,iPreFix:Integer;begin MS:=TMemoryStream.Create; try iPreFix:=0; iSize:=length(AStr) div 2; if iSize<=0 then exit; if (AStr[1]='0') and (AStr[2]='x') then iPreFix:=2; Dec(iSize,iPreFix); GetMem(bData,iSize); try HexToBin(PChar(AStr)+iPreFix,bData,iSize); MS.WriteBuffer(bData^,iSize); MS.Position:=0; finally FreeMem(bData); end; Bmp.LoadFromStream(MS); finally MS.Free; end;end;procedure TForm1.BitBtn1Click(Sender: TObject);begin StrToBmp(Memo1.Text,Image1.Picture.Bitmap);end;
 

Similar threads

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