JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_glutils_ETC1_decodeImage(JNIEnv* env, jclass clazz, jobject obj_compressedData, jint offset, jobject obj_decodedData, jint offsetDec, jint width, jint height, jint pixelSize) { char* compressedData = (char*)(obj_compressedData?env->GetDirectBufferAddress(obj_compressedData):0); char* decodedData = (char*)(obj_decodedData?env->GetDirectBufferAddress(obj_decodedData):0); //@line:249 etc1_decode_image((etc1_byte*)compressedData + offset, (etc1_byte*)decodedData + offsetDec, width, height, pixelSize, width * pixelSize); }
bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width, int height, Format format) { int dimX, dimY; GetBlockDimensions(format, &dimX, &dimY, true); if (width < 0 || ((width % dimX) != 0) || height < 0 || ((height % dimY) != 0)) { return false; } switch(format) { case kLATC_Format: DecompressLATC(dst, dstRowBytes, src, width, height); return true; case kR11_EAC_Format: DecompressR11EAC(dst, dstRowBytes, src, width, height); return true; #ifndef SK_IGNORE_ETC1_SUPPORT case kETC1_Format: return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowBytes); #endif case kASTC_4x4_Format: case kASTC_5x4_Format: case kASTC_5x5_Format: case kASTC_6x5_Format: case kASTC_6x6_Format: case kASTC_8x5_Format: case kASTC_8x6_Format: case kASTC_8x8_Format: case kASTC_10x5_Format: case kASTC_10x6_Format: case kASTC_10x8_Format: case kASTC_10x10_Format: case kASTC_12x10_Format: case kASTC_12x12_Format: DecompressASTC(dst, dstRowBytes, src, width, height, dimX, dimY); return true; default: // Do nothing... break; } return false; }
JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_glutils_ETC1_decodeImage (JNIEnv *env, jclass, jobject compressedData, jint offset, jobject decodedData, jint offsetDec, jint width, jint height, jint pixelSize) { etc1_byte* comprPtr = (etc1_byte*)env->GetDirectBufferAddress(compressedData) + offset; etc1_byte* imgPtr = (etc1_byte*)env->GetDirectBufferAddress(decodedData) + offsetDec; etc1_decode_image(comprPtr, imgPtr, width, height, pixelSize, width * pixelSize); }
KDuint8* xmReadTileETC ( KDFile* file, XMImage* image ) { ETCDecode* decode = (ETCDecode*) image->decode; KDuint8* pixels = 0; KDint block_size = 0; KDint32 tile_size = 0; if ( decode->pixels ) { kdFree ( decode->pixels ); decode->pixels = 0; } block_size = 8; tile_size = ( ( image->ptr_tile->width + 3 ) / 4 ) * ( ( image->ptr_tile->height + 3 ) / 4 ) * block_size; pixels = (KDuint8*) kdMalloc ( tile_size ); if ( !pixels ) { goto cleanup; } if ( kdFread ( pixels, tile_size, 1, file ) == 0 ) { //goto cleanup; } if ( decode->uncomp == 1 ) { tile_size = image->ptr_tile->width * image->ptr_tile->height * 3; decode->pixels = (KDuint8*) kdMalloc ( tile_size ); if ( decode->pixels ) { etc1_decode_image ( pixels, decode->pixels, image->ptr_tile->width, image->ptr_tile->height, 3, image->ptr_tile->width * 3 ); } kdFree ( pixels ); } else { decode->pixels = pixels; image->ptr_tile->size = tile_size; } decode->row_count = 0; image->ptr_tile->stride = tile_size / image->ptr_tile->height; return decode->pixels; cleanup : if ( pixels ) { kdFree ( pixels ); } return 0; }