- minor optimization in iOS image loader native code

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9916 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 4630638cd9
commit e45a75f2f6
  1. 3
      engine/src/ios/jme-ios.m

@ -64,17 +64,16 @@ Java_com_jme3_system_ios_IosImageLoader_loadImageData(JNIEnv* e, jclass obj, job
CGImageRef inImage = [inputImage CGImage];
int ht = CGImageGetWidth(inImage);
int wdth = CGImageGetHeight(inImage);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// NewDirectByteBuffer seems to fail? -> Creating ByteBuffer in java
jobject nativeBuffer = (*e)->CallStaticObjectMethod(e, bufferUtilsClass, newBufferMethod, ht*wdth*4);
if (checkJNIException(e)) {
CGColorSpaceRelease(colorSpace);
[inData release];
return nil;
}
void *rawData = (*e)->GetDirectBufferAddress(e, nativeBuffer);
NSUInteger bytesPerRowImg = CGImageGetBytesPerRow(inImage);
NSUInteger bitsPerComponentImg = CGImageGetBitsPerComponent(inImage);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(rawData,ht,wdth,bitsPerComponentImg,bytesPerRowImg,colorSpace,kCGImageAlphaPremultipliedLast| kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(context,CGRectMake(0,0,wdth,ht), inImage);

Loading…
Cancel
Save