From 17e9cd0f6d2ecdeaad481de5f1b78cd006f67ef0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 4 Nov 2015 17:12:13 -0500 Subject: [PATCH] fixed index images crop in PhotoCropBox --- Telegram/SourceFiles/boxes/photocropbox.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/photocropbox.cpp b/Telegram/SourceFiles/boxes/photocropbox.cpp index 9153ed9fd4..7805d4216c 100644 --- a/Telegram/SourceFiles/boxes/photocropbox.cpp +++ b/Telegram/SourceFiles/boxes/photocropbox.cpp @@ -267,7 +267,11 @@ void PhotoCropBox::onSend() { iw = from.height() - iy; } int32 offset = ix * from.depth() / 8 + iy * from.bytesPerLine(); - QImage cropped(from.bits() + offset, iw, iw, from.bytesPerLine(), from.format()), tosend; + QImage cropped(from.constBits() + offset, iw, iw, from.bytesPerLine(), from.format()), tosend; + if (from.format() == QImage::Format_Indexed8) { + cropped.setColorCount(from.colorCount()); + cropped.setColorTable(from.colorTable()); + } if (cropped.width() > 1280) { tosend = cropped.scaled(1280, 1280, Qt::KeepAspectRatio, Qt::SmoothTransformation); } else if (cropped.width() < 320) {