diff --git a/src/include/reprint.cpp b/src/include/reprint.cpp index fc5b786f3..7009ad854 100755 --- a/src/include/reprint.cpp +++ b/src/include/reprint.cpp @@ -1166,30 +1166,32 @@ void TBook::draw_image(const TReport_rct& rect, const char* filename, const char { TReport_rct new_rect(rect); - if (resize && *resize) + if (resize && *resize && filename && *filename) { TImage* img = _images.image(filename); - switch (resize[0]) + if (img != nullptr) { - case 'N': - new_rect.set_width(img->width()); - new_rect.set_height(img->height()); - break; - case 'X': + switch (resize[0]) { - long ratio = long((double(img->height()) / double(img->width())) * 100000.0); + case 'N': + new_rect.set_width(img->width()); + new_rect.set_height(img->height()); + break; + case 'X': + { + long ratio = long((double(img->height()) / double(img->width())) * 100000.0); short old_ysize = rect.height(); long new_ysize = rect.width() * ratio / 100000L; TReport_size s(rect.width(), (new_ysize * lpi()) / cpi()); - TReport_pnt o(rect.left(), rect.top() + ((old_ysize - new_ysize) * cpi())/ (2 * lpi())); + TReport_pnt o(rect.left(), rect.top() + ((old_ysize - new_ysize) * cpi()) / (2 * lpi())); new_rect.set(o, s); } break; - case 'Y': + case 'Y': { - long ratio = long((double(img->width()) / double(img->height())) * 100000.0); + long ratio = long((double(img->width()) / double(img->height())) * 100000.0); short old_xsize = rect.width(); long new_xsize = rect.height() * ratio / 100000L; TReport_size s((new_xsize * cpi()) / lpi(), rect.height()); @@ -1198,8 +1200,9 @@ void TBook::draw_image(const TReport_rct& rect, const char* filename, const char new_rect.set(o, s); } break; - default: - break; + default: + break; + } } } define_frame(new_rect);