From d7b21c9aebb8f6c94f8947eb0c5f46c76a4db3ef Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 27 Oct 2014 15:18:49 +0000 Subject: [PATCH] Replace assert with more helpful error --- panda/src/gobj/texture.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 99b4e2dc37..bd53fbdddb 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -3314,14 +3314,21 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa if (!alpha_fullpath.empty()) { // Make the original image a 4-component image by taking the // grayscale value from the second image. + image.add_alpha(); if (alpha_file_channel == 4 || (alpha_file_channel == 2 && alpha_image.get_num_channels() == 2)) { - // Use the alpha channel. - for (int x = 0; x < image.get_x_size(); x++) { - for (int y = 0; y < image.get_y_size(); y++) { - image.set_alpha(x, y, alpha_image.get_alpha(x, y)); + + if (!alpha_image.has_alpha()) { + gobj_cat.error() + << alpha_fullpath.get_basename() << " has no channel " << alpha_file_channel << ".\n"; + } else { + // Use the alpha channel. + for (int x = 0; x < image.get_x_size(); x++) { + for (int y = 0; y < image.get_y_size(); y++) { + image.set_alpha(x, y, alpha_image.get_alpha(x, y)); + } } } cdata->_alpha_file_channel = alpha_image.get_num_channels();