Dont use Format_Grayscale8

It's unnecessary work to support it
This commit is contained in:
Kovid Goyal 2016-05-09 17:44:13 +05:30
parent 6742cd5f10
commit 73a872b237
2 changed files with 2 additions and 4 deletions

View File

@ -416,10 +416,10 @@ QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, c
maximum_colors = MAX(2, MIN(MAX_COLORS, maximum_colors));
if (img.colorCount() > 0 && (size_t)img.colorCount() <= maximum_colors) return img; // Image is already quantized
if (img.hasAlphaChannel()) throw std::out_of_range("Cannot quantize image with transparency");
if (fmt != QImage::Format_RGB32 && fmt != QImage::Format_Indexed8 && fmt != 24) { // 24 = QImage::Format_Grayscale8
if (fmt != QImage::Format_RGB32 && fmt != QImage::Format_Indexed8) {
img = img.convertToFormat(QImage::Format_RGB32);
if (img.isNull()) throw std::bad_alloc();
} else if (fmt == 24) img = img.convertToFormat(QImage::Format_Indexed8);
}
// There can be no more than MAX_LEAVES * 8 nodes. Add 1 in case there is an off by 1 error somewhere.
Pool<Node> node_pool((MAX_LEAVES + 1) * 8);
if (palette.size() > 0) {

View File

@ -156,8 +156,6 @@ def add_borders_to_image(img_data, left=0, top=0, right=0, bottom=0,
return image_to_data(img, fmt=fmt)
def to_grayscale(img):
if hasattr(QImage, 'Format_Grayscale8'):
return img.convertToFormat(QImage.Format_Grayscale8)
if imageops is not None:
return imageops.grayscale(img)
return img