Commit 820eacf
authored
Optimize QRColorMask apply_mask method for enhanced performance
This commit introduces optimizations to the apply_mask method in the QRColorMask class to improve performance. Changes include:
1. Replacing getpixel and putpixel with direct pixel manipulation using the load() method, which speeds up the process.
2. Implementing a caching mechanism to reuse color transformations for identical pixel colors, reducing redundant calculations.
3. Adding conditions to skip processing for background color pixels to reduce computational load.
These optimizations have significantly reduced the method's execution time. In some experiments, these changes have resulted in performance improvements of over ten times compared to the original method, especially for larger images.1 parent d44a409 commit 820eacf
1 file changed
+16
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | | - | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
0 commit comments