Browse Source

Optimized display visualization

Thomas Buck 9 years ago
parent
commit
620c32684b
2 changed files with 7 additions and 6 deletions
  1. 6
    5
      CaseLights/AppDelegate.m
  2. 1
    1
      CaseLights/Info.plist

+ 6
- 5
CaseLights/AppDelegate.m View File

622
 
622
 
623
 - (void)visualizeDisplay:(NSTimer *)timer {
623
 - (void)visualizeDisplay:(NSTimer *)timer {
624
     NSBitmapImageRep *screen = [Screenshot screenshot:[timer userInfo]];
624
     NSBitmapImageRep *screen = [Screenshot screenshot:[timer userInfo]];
625
+    NSInteger spp = [screen samplesPerPixel];
625
     
626
     
626
-    if ((([screen samplesPerPixel] != 3) && ([screen samplesPerPixel] != 4)) || ([screen isPlanar] == YES) || ([screen numberOfPlanes] != 1)) {
627
-        NSLog(@"Unknown image format (%ld, %c, %ld)!\n", (long)[screen samplesPerPixel], ([screen isPlanar] == YES) ? 'p' : 'n', (long)[screen numberOfPlanes]);
627
+    if (((spp != 3) && (spp != 4)) || ([screen isPlanar] == YES) || ([screen numberOfPlanes] != 1)) {
628
+        NSLog(@"Unknown image format (%ld, %c, %ld)!\n", (long)spp, ([screen isPlanar] == YES) ? 'p' : 'n', (long)[screen numberOfPlanes]);
628
         return;
629
         return;
629
     }
630
     }
630
     
631
     
639
     unsigned long long max = width * height;
640
     unsigned long long max = width * height;
640
     unsigned long long red = 0, green = 0, blue = 0;
641
     unsigned long long red = 0, green = 0, blue = 0;
641
     for (unsigned long long i = 0; i < max; i++) {
642
     for (unsigned long long i = 0; i < max; i++) {
642
-        red += data[([screen samplesPerPixel] * i) + redC];
643
-        green += data[([screen samplesPerPixel] * i) + greenC];
644
-        blue += data[([screen samplesPerPixel] * i) + blueC];
643
+        red += data[(spp * i) + redC];
644
+        green += data[(spp * i) + greenC];
645
+        blue += data[(spp * i) + blueC];
645
     }
646
     }
646
     
647
     
647
     [self setLightsR:(red / max) G:(green / max) B:(blue / max)];
648
     [self setLightsR:(red / max) G:(green / max) B:(blue / max)];

+ 1
- 1
CaseLights/Info.plist View File

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>132</string>
24
+	<string>142</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

Loading…
Cancel
Save