소스 검색

- minor optimization in iOS image loader native code

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9916 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 13 년 전
부모
커밋
e45a75f2f6
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      engine/src/ios/jme-ios.m

+ 1 - 2
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);