MCPcopy Create free account
hub / github.com/defold/defold / read_source_images

Method read_source_images

engine/dlib/src/basis/encoder/basisu_comp.cpp:466–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464 }
465
466 bool basis_compressor::read_source_images()
467 {
468 debug_printf("basis_compressor::read_source_images\n");
469
470 const uint32_t total_source_files = m_params.m_read_source_images ? (uint32_t)m_params.m_source_filenames.size() : (uint32_t)m_params.m_source_images.size();
471 if (!total_source_files)
472 return false;
473
474 m_stats.resize(0);
475 m_slice_descs.resize(0);
476 m_slice_images.resize(0);
477
478 m_total_blocks = 0;
479 uint32_t total_macroblocks = 0;
480
481 m_any_source_image_has_alpha = false;
482
483 basisu::vector<image> source_images;
484 basisu::vector<std::string> source_filenames;
485
486 // First load all source images, and determine if any have an alpha channel.
487 for (uint32_t source_file_index = 0; source_file_index < total_source_files; source_file_index++)
488 {
489 const char *pSource_filename = "";
490
491 image file_image;
492
493 if (m_params.m_read_source_images)
494 {
495 pSource_filename = m_params.m_source_filenames[source_file_index].c_str();
496
497 // Load the source image
498 if (!load_image(pSource_filename, file_image))
499 {
500 error_printf("Failed reading source image: %s\n", pSource_filename);
501 return false;
502 }
503
504 if (m_params.m_status_output)
505 {
506 printf("Read source image \"%s\", %ux%u\n", pSource_filename, file_image.get_width(), file_image.get_height());
507 }
508
509 // Optionally load another image and put a grayscale version of it into the alpha channel.
510 if ((source_file_index < m_params.m_source_alpha_filenames.size()) && (m_params.m_source_alpha_filenames[source_file_index].size()))
511 {
512 const char *pSource_alpha_image = m_params.m_source_alpha_filenames[source_file_index].c_str();
513
514 image alpha_data;
515
516 if (!load_image(pSource_alpha_image, alpha_data))
517 {
518 error_printf("Failed reading source image: %s\n", pSource_alpha_image);
519 return false;
520 }
521
522 printf("Read source alpha image \"%s\", %ux%u\n", pSource_alpha_image, alpha_data.get_width(), alpha_data.get_height());
523

Callers

nothing calls this directly

Calls 15

debug_printfFunction · 0.85
error_printfFunction · 0.85
image_resampleFunction · 0.85
string_formatFunction · 0.85
enlarge_vectorFunction · 0.85
get_709_lumaMethod · 0.80
set_noclamp_rgbaMethod · 0.80
has_alphaMethod · 0.80
load_imageFunction · 0.70
maximumFunction · 0.70
save_pngFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected