mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont use Format_Grayscale8
It's unnecessary work to support it
This commit is contained in:
parent
6742cd5f10
commit
73a872b237
@ -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));
|
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.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 (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);
|
img = img.convertToFormat(QImage::Format_RGB32);
|
||||||
if (img.isNull()) throw std::bad_alloc();
|
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.
|
// 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);
|
Pool<Node> node_pool((MAX_LEAVES + 1) * 8);
|
||||||
if (palette.size() > 0) {
|
if (palette.size() > 0) {
|
||||||
|
@ -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)
|
return image_to_data(img, fmt=fmt)
|
||||||
|
|
||||||
def to_grayscale(img):
|
def to_grayscale(img):
|
||||||
if hasattr(QImage, 'Format_Grayscale8'):
|
|
||||||
return img.convertToFormat(QImage.Format_Grayscale8)
|
|
||||||
if imageops is not None:
|
if imageops is not None:
|
||||||
return imageops.grayscale(img)
|
return imageops.grayscale(img)
|
||||||
return img
|
return img
|
||||||
|
Loading…
x
Reference in New Issue
Block a user