464 kCGColorSpaceGenericRGB); 465 CGContextRef jPicContextRef = CGBitmapContextCreate( 466 javaPixels, 467 pixWidth, pixHeight, 468 8, pixWidth * sizeof(jint), 469 picColorSpace, 470 kCGBitmapByteOrder32Host | 471 kCGImageAlphaPremultipliedFirst); 472 473 CGColorSpaceRelease(picColorSpace); 474 475 // flip, scale, and color correct the screen image into the Java pixels 476 CGRect zeroBounds = { { 0, 0 }, { pixWidth, pixHeight } }; 477 CGContextDrawImage(jPicContextRef, zeroBounds, screenImage); 478 CGContextFlush(jPicContextRef); 479 480 // cleanup 481 CGContextRelease(jPicContextRef); 482 (*env)->ReleaseIntArrayElements(env, pixelArray, javaPixels, 0); 483 484 jfloat scale = (*env)->CallStaticFloatMethod(env, 485 [GlassHelper ClassForName:"com.sun.glass.ui.Application" withEnv:env], 486 javaIDs.Application.getScaleFactor, x, y, width, height); 487 if ((*env)->ExceptionCheck(env)) return NULL; 488 489 // create Pixels 490 pixels = (*env)->CallStaticObjectMethod(env, 491 [GlassHelper ClassForName:"com.sun.glass.ui.Application" withEnv:env], 492 javaIDs.Application.createPixels, pixWidth, pixHeight, pixelArray, scale, scale); 493 if ((*env)->ExceptionCheck(env)) return NULL; 494 } 495 } 496 497 CGImageRelease(screenImage); 498 } 499 } 500 GLASS_POOL_EXIT; 501 502 return pixels; 503 } | 464 kCGColorSpaceGenericRGB); 465 CGContextRef jPicContextRef = CGBitmapContextCreate( 466 javaPixels, 467 pixWidth, pixHeight, 468 8, pixWidth * sizeof(jint), 469 picColorSpace, 470 kCGBitmapByteOrder32Host | 471 kCGImageAlphaPremultipliedFirst); 472 473 CGColorSpaceRelease(picColorSpace); 474 475 // flip, scale, and color correct the screen image into the Java pixels 476 CGRect zeroBounds = { { 0, 0 }, { pixWidth, pixHeight } }; 477 CGContextDrawImage(jPicContextRef, zeroBounds, screenImage); 478 CGContextFlush(jPicContextRef); 479 480 // cleanup 481 CGContextRelease(jPicContextRef); 482 (*env)->ReleaseIntArrayElements(env, pixelArray, javaPixels, 0); 483 484 jclass applicationClass = 485 [GlassHelper ClassForName:"com.sun.glass.ui.Application" withEnv:env]; 486 if (!applicationClass) return NULL; 487 488 jfloat scale = (*env)->CallStaticFloatMethod(env, 489 applicationClass, 490 javaIDs.Application.getScaleFactor, x, y, width, height); 491 if ((*env)->ExceptionCheck(env)) return NULL; 492 493 // create Pixels 494 pixels = (*env)->CallStaticObjectMethod(env, applicationClass, 495 javaIDs.Application.createPixels, 496 pixWidth, pixHeight, 497 pixelArray, scale, scale); 498 if ((*env)->ExceptionCheck(env)) return NULL; 499 } 500 } 501 502 CGImageRelease(screenImage); 503 } 504 } 505 GLASS_POOL_EXIT; 506 507 return pixels; 508 } |