请问如何把图片转换成字符串

解决方案 »

  1.   

    可以放一个image控件,然后把图像load进来,然后保存成资源文件就可以了,这时图片就转换成字符串了
      

  2.   

    最简单的方法!:用image组件装要转换的图画
           按ctrl+c复制image组件
           切换到代码窗口,ctrl+v
           picture.date里的就是该图画的字符串,非常好用 :)
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    function b2c( b: Byte ):Char;
    begin
      case b of
       0: result := '0';
       1: result := '1';
       2: result := '2';
       3: result := '3';4: result := '4';5: result := '5';
       6: result := '6';7: result := '7';8: result := '8';
       9: result := '9';10: result := 'A';11: result := 'B';
       12: result := 'C';13: result := 'D';14: result := 'E';
      else result := 'F';
      end;
    end;
    var
      fm : TFileStream;
      buf : PByte;
      p : PByte;
      s : string;
      i, j, size : Integer;   k:dword;
    begin
      if not OpenDlg1.Execute then
         exit;  fm := TFileStream.Create( OpenDlg1.FileName,fmOpenRead );
      size := fm.Size;
      buf := AllocMem( size );
      fm.Read( buf^, size );
      fm.Free;
                                     k:= GetTickCount();
      SetLength( s, size * 2 + (size div 16) * 2 );
      i := 1;
      j := 0;
      p := buf;
      repeat
        s[i] := b2c( p^ shr 4 );
        Inc( i );
        s[i] := b2c( p^ and $0F );
        Inc( i );
        Inc( p );
        Inc( j );
        if j = 16 then
        begin
          j := 0;
          s[i] := #13;
          Inc( i );
          s[i] := #10;
          Inc( i );
        end;
      until i > Length(s);      caption := IntToStr(GetTickCount()-k);
      Memo1.Lines.Text := s;
    end;
    http://expert.csdn.net/Expert/topic/2809/2809573.xml?temp=.2032892