From 1eee97f459cc2ece29cf94be84f4b0ff82a716e4 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 31 May 2001 01:20:37 +0000 Subject: [PATCH] fix bug with accessing invalid texture --- pandatool/src/egg-palettize/destTextureImage.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandatool/src/egg-palettize/destTextureImage.cxx b/pandatool/src/egg-palettize/destTextureImage.cxx index 7f7a0b2611..f627d6d3e6 100644 --- a/pandatool/src/egg-palettize/destTextureImage.cxx +++ b/pandatool/src/egg-palettize/destTextureImage.cxx @@ -70,10 +70,18 @@ DestTextureImage(TexturePlacement *placement) { void DestTextureImage:: copy(TextureImage *texture) { const PNMImage &source_image = texture->read_source_image(); - PNMImage dest_image(_x_size, _y_size, texture->get_num_channels(), - source_image.get_maxval()); - dest_image.quick_filter_from(source_image); - write(dest_image); + if (source_image.is_valid()) { + PNMImage dest_image(_x_size, _y_size, texture->get_num_channels(), + source_image.get_maxval()); + dest_image.quick_filter_from(source_image); + write(dest_image); + + } else { + // Couldn't read the texture, so fill it with red. + PNMImage dest_image(_x_size, _y_size, texture->get_num_channels()); + dest_image.fill(1.0, 0.0, 0.0); + write(dest_image); + } } ////////////////////////////////////////////////////////////////////