2012-07-10 54 views
1

我试图创建一个远程桌面式的程序,我目前正在试图让我的远程PC上什么图像,背在发送到我的客户端电脑,来更新自己的形象(这种情况发生过2-3秒)。传递位图/ JPEG通过网络

我目前拿到桌面的图像是这样的:

// Set up a bitmap of the correct size 
     Bitmap CapturedImage = new Bitmap((int)SystemInformation.VirtualScreen.Width, 
      (int)SystemInformation.VirtualScreen.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565); 

     // Create a graphics object from it 
     System.Drawing.Size size = new System.Drawing.Size((int)SystemInformation.VirtualScreen.Width, (int)SystemInformation.VirtualScreen.Height); 

     using (Graphics gr = Graphics.FromImage(CapturedImage)) 
     { 
      // copy the entire screen to the bitmap 
      gr.CopyFromScreen(0, 0, 0, 0, 
       size, CopyPixelOperation.SourceCopy); 
     } 

     EncodeToJPEG(CapturedImage); 

而且EncodeToJPEG看起来是这样的:

var qualityEncoder = Encoder.Quality; 
     var quality = (long)0; 
     var ratio = new EncoderParameter(qualityEncoder, quality); 
     var codecParams = new EncoderParameters(1); 
     codecParams.Param[0] = ratio; 
     var jpegCodecInfo = GetEncoder(ImageFormat.Jpeg); 
     capturedImage.Save(@"c:\Test.jpg", jpegCodecInfo, codecParams); // Save to JPG 

我的问题来自于保存 方法。我想知道是否有一种方法可以临时存储这张JPG,只要我能够通过网络发回,而不是将其保存到文件中?像,我可以返回一个压缩的JPG图像对象吗?或者这是不可能的这种方式?

我也听说了这些目的,将图像分割成块,并检查他们的三角洲,只发回的变化更快,更新这样的图像的最有效方法。如果任何人有任何在该部门的指针,我会非常感激。

回答

3

编码器具有保存

Arugument超载名的方法传递是流

您将保存到的MemoryStream的内存块保存

没有文件!

最佳,

PRASHANT :)