Datasnap Image

Posted lypzxy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Datasnap Image相关的知识,希望对你有一定的参考价值。

delphi用,不能与java、c#互相识别。

procedure TServerMethods.UpdateDoc(ItemID : integer; doc : TStream);

 

delphi用,不能与java、c#互相识别。

procedure TServerMethods.UpLoadFile(ADoc: TJSONArray);

jsonArray := TDBXJSONTools.StreamToJSON(aStream, 0, aStream.Size);

bstream := TDBXJSONTools.JSONToStream(jsonArray);

procedure TForm2.Button4Click(Sender: TObject);
var
  jpg, jpg2: TJPEGImage;
  aStream: TMemoryStream;
  bstream: TStream;
  jsonArray: TJSONArray;
begin
  jpg := TJPEGImage.Create;
  jpg.LoadFromFile(\'e:\\test.jpg\');
  Image1.Picture.Assign(jpg);

  aStream := TMemoryStream.Create;
  jpg.SaveToStream(aStream);

  aStream.Position := 0;
  jsonArray := TDBXJSONTools.StreamToJSON(aStream, 0, aStream.Size);
  RichEdit1.Text := jsonArray.Value;
  RichEdit1.Text := jsonArray.ToString;
  RichEdit1.Text := jsonArray.ToJSON; // 纯数字 不能跨语言 java c#互相识别

  // jsonArray:= TJSONObject.ParseJSONValue(RichEdit1.Text);
  bstream := TDBXJSONTools.JSONToStream(jsonArray);
  jpg2 := TJPEGImage.Create;
  bstream.Position := 0;
  jpg2.LoadFromStream(bstream);
  Image2.Picture.Assign(jpg2);
  jpg.Free;
end;
View Code

 

http://www.cnblogs.com/codingnote/archive/2012/04/09/2438673.html

http://stackoverflow.com/questions/16550915/how-to-convert-a-json-string-to-an-image

 http://blog.csdn.net/shandiantianying/article/details/9022121

string,base64

 

 class function CreateTDataSetFromJSON(value: TJSONObject): TDataset;
 class function TDataSetToJSONObject(value: TDataset): TJSONObject;

跨语言C#、java

Delphi读取b64字符串

procedure TForm2.Button3Click(Sender: TObject);
var
  strStream: TStringStream;
  b64: TBase64Encoding;
  aStream: TMemoryStream;
  jpg2: TJPEGImage;
begin
  strStream := TStringStream.Create;
  strStream.LoadFromFile(\'e:\\b64CSharp.txt\');
  strStream.Position := 0;

  b64 := TBase64Encoding.Create;
  aStream := TMemoryStream.Create;
  b64.Decode(strStream, aStream);
  aStream.Position := 0;
  jpg2 := TJPEGImage.Create;
  jpg2.LoadFromStream(aStream);

  Image2.Picture.Assign(jpg2);

  strStream.Free;
  b64.Free;
  aStream.Free;
  jpg2.Free;

end;

c#图片base64编码

        private void button1_Click(object sender, EventArgs e)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.Drawing.Bitmap bp = new Bitmap(@"e:\\test.jpg");
            bp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] b = ms.GetBuffer();

            this.richTextBox1.Text = Convert.ToBase64String(b);
             
        }

 C#图片baes64解码

byte[] bt = Convert.FromBase64String(base64string);
System.IO.MemoryStream stream = new System.IO.MemoryStream(bt);
Bitmap bitmap = new Bitmap(stream);
pictureBox1.Image = bitmap;

Vcl.Imaging.pngimage.hpp

 TPngImage

以上是关于Datasnap Image的主要内容,如果未能解决你的问题,请参考以下文章

IdHttpServer实现webservice(130篇DataSnap文章)

DATASNAP数据提交之FIREDAC的TFDJSONDeltas

datasnap 授权验证DSAuthenticationManager方法应用

delphi datasnap service服务叫啥

delphi 中的datasnap 是啥意思 Developing Datasnap Application 中文意思是啥

idhttp.post方式 调用datasnap rest 远程方法