MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / preProcessImageToCache

Function preProcessImageToCache

tools/aapt/Images.cpp:1363–1488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363status_t preProcessImageToCache(const Bundle* bundle, const String8& source, const String8& dest)
1364{
1365 png_structp read_ptr = NULL;
1366 png_infop read_info = NULL;
1367
1368 FILE* fp;
1369
1370 image_info imageInfo;
1371
1372 png_structp write_ptr = NULL;
1373 png_infop write_info = NULL;
1374
1375 status_t error = UNKNOWN_ERROR;
1376
1377 if (bundle->getVerbose()) {
1378 printf("Processing image to cache: %s => %s\n", source.string(), dest.string());
1379 }
1380
1381 // Get a file handler to read from
1382 fp = fopen(source.string(),"rb");
1383 if (fp == NULL) {
1384 fprintf(stderr, "%s ERROR: Unable to open PNG file\n", source.string());
1385 return error;
1386 }
1387
1388 // Call libpng to get a struct to read image data into
1389 read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1390 if (!read_ptr) {
1391 fclose(fp);
1392 png_destroy_read_struct(&read_ptr, &read_info,NULL);
1393 return error;
1394 }
1395
1396 // Call libpng to get a struct to read image info into
1397 read_info = png_create_info_struct(read_ptr);
1398 if (!read_info) {
1399 fclose(fp);
1400 png_destroy_read_struct(&read_ptr, &read_info,NULL);
1401 return error;
1402 }
1403
1404 // Set a jump point for libpng to long jump back to on error
1405 if (setjmp(png_jmpbuf(read_ptr))) {
1406 fclose(fp);
1407 png_destroy_read_struct(&read_ptr, &read_info,NULL);
1408 return error;
1409 }
1410
1411 // Set up libpng to read from our file.
1412 png_init_io(read_ptr,fp);
1413
1414 // Actually read data from the file
1415 read_png(source.string(), read_ptr, read_info, &imageInfo);
1416
1417 // We're done reading so we can clean up
1418 // Find old file size before releasing handle
1419 fseek(fp, 0, SEEK_END);
1420 size_t oldSize = (size_t)ftell(fp);

Callers 2

doSingleCrunchFunction · 0.85
processImageMethod · 0.85

Calls 6

read_pngFunction · 0.85
do_9patchFunction · 0.85
write_pngFunction · 0.85
getVerboseMethod · 0.80
stringMethod · 0.80
getGrayscaleToleranceMethod · 0.80

Tested by

no test coverage detected