| |

VerySource

 Forgot password?
 Register
Search
View: 667|Reply: 4

GetPixel () SetPixel () execution efficiency

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-22 22:00:01
| Show all posts |Read mode
Advice I have the following code to deepen the brightness of pixels in an area
The efficiency of actual execution is too slow.A better solution is required.

COLORREF rgb;
BYTE r, g, b;
for (UINT x = 0; x <xMax; x ++)
{
  for (UINT y = 0; y <yMax; y ++)
  {
    rgb = GetPixel (x, y);
    r = GetR (rgb);
    g = GetG (rgb);
    b = GetB (rgb);
    r + = 20; g + = 20; b + = 20; // The overflow problem need not be considered ... small hidden dangers ...
    SetPixel (x, y, RGB (r, g, b);
  }
}
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-4 20:45:01
| Show all posts
Do not display pixels one by one, display them together after modification in the memory
Reply

Use magic Report

0

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-5 22:00:02
| Show all posts
Agree upstairs!
Cache it.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-12 09:15:01
| Show all posts
Is the modified memDC
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-7-13 18:15:02
| Show all posts
You can use GetObject to get the graphic data pointer, and then directly operate
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list