Arsip: Konversi Bitmap ke Text atau Text ke Bitmap


by adludin in Articles more 14 years ago 1606
Procedure di bawah berguna untuk melakukan konversi dari bitmap ke text ataupun sebaliknya...
#F8F8F8cellpadding = 2 cellspacing = 2>
procedure BitmapToText(Bmp:TBitmap;var strBmp:string);
var aStrStream:TStringStream;
begin
  aStrStream:=TStringStream.Create('');
  try
    bmp.SaveToStream(aStrStream);
    strBmp:=astrStream.DataString;
  finally
    astrStream.Free;
  end;
end;
procedure TextToBitmap(const
strBmp:string;Bmp:TBitmap)
var aStrStream:TStringStream;
begin
  aStrStream:=TStringStream.Create(strBmp);
  try
    bmp.LoadFromStream(aStrStream);
  finally
    astrStream.Free;
  end;
end;
Utk instance kelas TJPEGImage caranya sama, cuma ganti TBitmap dengan TJPEGImage. TStringStream dideklarasikan di unit classes.pas. Contoh:#F8F8F8cellpadding = 2 cellspacing = 2>
//menampilkan data bitmap kedalam memo
BitmapToText(Image1.Picture.Bitmap,Memo1.Text);
//mengkopi data di memo ke suatu bitmap
TextToBitmap(Memo1.Text,Bitmap2);
Bitmap2.SaveToFile('copy.bmp');
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com