客户端:截图->压缩成JPEG->保到TMemoryStream 中->传送至服务器
服务端:接收数据->保存到TMemoryStream中->显示在IMAGE中
现在传输成功了,且服务端能收到完整的数据。就是不知该怎么显示。请赐教!
var
jpeg:TJPEGImage;
......
athread.Connection.ReadStream(stream,buf.size,false);//接收数据至stream
//stream.savetofile('a.jpg');//如果加上这句确实有图片被保存。
jpeg.loadfromstream(stream);
image1.Picture.Bitmap.Assign(jpeg);
提示有 JPEG ERROR #42 错误!
9 个解决方案
#1
我也正在做类似屏幕传输的程序,请问你做的是不是只能一对一传送屏幕?
#2
jpeg还得解压成BMP类型,bitMap只认BMP格式的哦。
#3
TmpBmp,Scimg:TBitMap;
LoadFirst(Astream:TStream );
var
P:TPoint;
ssize,i,ss:Integer;
R:TRect;
begin
if not Assigned(tmpstream1) then tmpstream1:=TMemoryStream.Create;
MyDeCompress(Astream );
ss:= Astream.Size;
Astream.Seek(0,soFromBeginning );
Astream.Read(p,SizeOf(p));
Scimg.SetSize(p.x,p.Y );
Image1.Width := p.X;
Image1.Height := p.Y;
Scimg.LoadFromStream(Astream);
//Form1.Image1.Canvas.Draw(0,0,TmpBmp);
R:= Rect(0,0,Image1.Width,Image1.Height);
Form1.Image1.Canvas.StretchDraw(R,Scimg);
这是一段代码,自己去整理一下,绝对可以。
LoadFirst(Astream:TStream );
var
P:TPoint;
ssize,i,ss:Integer;
R:TRect;
begin
if not Assigned(tmpstream1) then tmpstream1:=TMemoryStream.Create;
MyDeCompress(Astream );
ss:= Astream.Size;
Astream.Seek(0,soFromBeginning );
Astream.Read(p,SizeOf(p));
Scimg.SetSize(p.x,p.Y );
Image1.Width := p.X;
Image1.Height := p.Y;
Scimg.LoadFromStream(Astream);
//Form1.Image1.Canvas.Draw(0,0,TmpBmp);
R:= Rect(0,0,Image1.Width,Image1.Height);
Form1.Image1.Canvas.StretchDraw(R,Scimg);
这是一段代码,自己去整理一下,绝对可以。
#4
跟我一样的菜鸟,我也是刚弄好.哈哈 QQ:396107263
#5
image1.Picture.Bitmap.Assign(jpeg);
====================================
image1.Picture.Assign(jpeg);
====================================
image1.Picture.Assign(jpeg);
#6
要对图像数据进行Base64编码.
#7
lz要干嘛?
#8
不知,帮顶
#9
以后需再关注,现在先帮你顶一下
#1
我也正在做类似屏幕传输的程序,请问你做的是不是只能一对一传送屏幕?
#2
jpeg还得解压成BMP类型,bitMap只认BMP格式的哦。
#3
TmpBmp,Scimg:TBitMap;
LoadFirst(Astream:TStream );
var
P:TPoint;
ssize,i,ss:Integer;
R:TRect;
begin
if not Assigned(tmpstream1) then tmpstream1:=TMemoryStream.Create;
MyDeCompress(Astream );
ss:= Astream.Size;
Astream.Seek(0,soFromBeginning );
Astream.Read(p,SizeOf(p));
Scimg.SetSize(p.x,p.Y );
Image1.Width := p.X;
Image1.Height := p.Y;
Scimg.LoadFromStream(Astream);
//Form1.Image1.Canvas.Draw(0,0,TmpBmp);
R:= Rect(0,0,Image1.Width,Image1.Height);
Form1.Image1.Canvas.StretchDraw(R,Scimg);
这是一段代码,自己去整理一下,绝对可以。
LoadFirst(Astream:TStream );
var
P:TPoint;
ssize,i,ss:Integer;
R:TRect;
begin
if not Assigned(tmpstream1) then tmpstream1:=TMemoryStream.Create;
MyDeCompress(Astream );
ss:= Astream.Size;
Astream.Seek(0,soFromBeginning );
Astream.Read(p,SizeOf(p));
Scimg.SetSize(p.x,p.Y );
Image1.Width := p.X;
Image1.Height := p.Y;
Scimg.LoadFromStream(Astream);
//Form1.Image1.Canvas.Draw(0,0,TmpBmp);
R:= Rect(0,0,Image1.Width,Image1.Height);
Form1.Image1.Canvas.StretchDraw(R,Scimg);
这是一段代码,自己去整理一下,绝对可以。
#4
跟我一样的菜鸟,我也是刚弄好.哈哈 QQ:396107263
#5
image1.Picture.Bitmap.Assign(jpeg);
====================================
image1.Picture.Assign(jpeg);
====================================
image1.Picture.Assign(jpeg);
#6
要对图像数据进行Base64编码.
#7
lz要干嘛?
#8
不知,帮顶
#9
以后需再关注,现在先帮你顶一下