Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:36:56+00:00 2026-06-10T20:36:56+00:00

Not sure if what I’m trying to do will work out, or is even

  • 0

Not sure if what I’m trying to do will work out, or is even possible. Basically I’m creating a remote desktop type app which captures the screen as a jpeg image and sends it to the client app for displaying.
I want to reduce the amount of data sent each time by comparing the image to the older one and only sending the differences. For example:

var bitmap = new Bitmap(1024, 720);

string oldBase = "";

using (var stream = new MemoryStream())
using (var graphics = Graphics.FromImage(bitmap))
{
    graphics.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size);
    bitmap.Save(stream, ImageFormat.Jpeg);
    string newBase = Convert.ToBase64String(stream.ToArray());

    // ! Do compare/replace stuff here with newBase and oldBase !

    // Store the old image as a base64 string.
    oldBase = newBase;
}

Using something like this I could compare both base64 strings and replace any matches. The matched text could be replaced with something like:

[number of characters replaced]

That way, on the client side I know where to replace the old data and add the new. Again, I’m not sure if this would even work so anyones thoughts on this would be very appreciated. 🙂 If it is possible, could you point me in the right direction? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:36:57+00:00Added an answer on June 10, 2026 at 8:36 pm

    You can do this by comparing the bitmap bits directly. Look into Bitmap.LockBits, which will give you a BitmapData pointer from which you can get the pixel data. You can then compare the pixels for each scan line and encode them into whatever format you want to use for transport.

    Note that a scan line’s length in bytes is always a multiple of 4. So unless you’re using 32-bit color, you have to take into account the padding that might be at the end of the scan line. That’s what the Stride property is for in the BitmapData structure.

    Doing things on a per-scanline basis is easier, but potentially not as efficient (in terms of reducing the amount of data sent) as treating the bitmap as one contiguous block of data. Your transport format should look something like:

    <start marker>
    // for each scan line
    <scan line marker><scan line number>
    <pixel position><number of pixels><pixel data>
    <pixel position><number of pixels><pixel data>
    ...
    // next scan line
    <scan line marker><scan line number>
    ...
    <end marker>
    

    each <pixel position><number of pixels><pixel data> entry is a run of changed pixels. If a scan line has no changed pixels, you can choose not to send it. Or you can just send the scan line marker and number, followed immediately by the next scan line.

    Two bytes will be enough for the <pixel position> field and for the <number of pixels> field. So you have an overhead of four bytes for each block. An optimization you might be interested in, after you have the simplest version working, would be to combine blocks of changed/unchanged pixels if there are small runs. For example, if you have uucucuc, where u is an unchanged pixel and c is a changed pixel, you’ll probably want to encode the cucuc as one run of five changed pixels. That will reduce the amount of data you have to transmit.

    Note that this isn’t the best way to do things, but it’s simple, effective, and relatively easy to implement.

    In any case, once you’ve encoded things, you can run the data through the built-in GZip compressor (although doing so might not help much) and then push it down the pipe to the client, which would decompress it and interpret the result.

    It would be easiest to build this on a single machine, using two windows to verify the results. Once that’s working, you can hook up the network transport piece. Debugging the initial cut by having that transport step in the middle could prove very frustrating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is even possible, but I think it's worth asking. What
not sure if this is possible keeping the code simple, but im trying to
Not sure if im just being stupid or something but here goes i work
Not sure if this is possible: I want to use datatables to manipulate my
Not sure what's going on here, but in my Rails 3 application, I type
Not sure how to explain it and can't seem to figure out why this
Not sure if that the right title for the question, but what I'm trying
Not sure what I'm doing wrong here. Just trying to make it a modal
not sure if this is possible without having to go through several passes, but
not sure if this make sense at all im trying to understand how C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.