Display a bitmap as fast as technically possible!

Started by
24 comments, last by David Lake 12 years, 1 month ago
Do note that time is also a scarce resource, and is seldom free.

I do appreciate that you want to learn this stuff anyway, but then you have to be willing to invest unknown amount of time into the project - you don't know when you're ready until you actually are ready.

Again, approach the problem systematically, piece by piece, and then finish the puzzle when you have all the individual pieces at hand. You don't need all the pieces to begin solving it, though.

Niko Suni

Advertisement
Regarding partial surface updates:

The common need to update just specific rectangles of a graphics memory area is the specific reason why D3D Lock* and Update* methods have rectangles as parameters. It is simply more efficient to just copy the actually changed data than blindly copy it all (if you can efficiently detect the changed areas).

It isn't very difficult to detect what specific areas of a desktop have changed, and express the changed areas as lists of rectangles. If you capture and send the images within those rectangles, the combined amount of data is likely much smaller than what the full desktop image requires.

On the drawing side, only draw the data that you actually get. And if you don't have all the data that you need to fill the frame, request the full frame image (commonly known as keyframe) from the remote desktop server and track changes from that.

Niko Suni

If i can calculate the difference between the current and last frame and set the alpha as well as rgb channels of the unchanged pixels to zero so the unchanged areas can be compressed out by the png compression then just lay the new frame over the last one at the other end.
something like this:
Parallel.For(0, bmp.Height, i =>{
for (int j = 1; j < bmp.Width; j++){
if (bmp.GetPixel(j, i) == _currentbmp.GetPixel(j, i)){
bmp.SetPixel(j, i, Color.FromArgb(0, 0, 0, 0));
}
}
});


it looks like I dont even need to change the recieving end as the image is drawn over the old one and the transparent parts will show the unchanged pixels on the old image I just need to make my loop work.
I still need help with this I am trying hard but finding a way round the slow Get/SetPixel aint easy.
Per-pixel operations are going to be slow. Use block copies for optimum performance (hint: image rectangles are rows of blocks).

Niko Suni

So I cant process the image how I want at a reasonable speed? what about making the gpu do it im using getfrontbufferdata to capture the screen cant i process it somehow with slimdx then transfer it to system memory?
Ok iv somehow got my program to to about 20fps!!! the speed is insane!!! but im not quite sure how but theres 1 slight problem when i save a surface to a bmp instead of png the image is magnified and the right and bottom are cutoff what the hell is doing this?
Not only that but I was running x64, now i'm running x86 its going even faster at about 20-30fps its smooth enuf to watch a movie in!!!
I figured out why the image was being stretched I just needed to specify the dimensions when calling DrawImage!
Now hows about some help with my idea of blanking unchanged pixels to make the frames smaller what would be the code for doing this?

This topic is closed to new replies.

Advertisement