Avoid unnecessary detach when saving to BMP.
Task-number: QTBUG-11486 Change-Id: Ic9aa733da4f23dc3eaba111c97a39bfd911f8cb3 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
parent
1838a6c2fb
commit
c7e21f3923
@ -624,7 +624,7 @@ bool qt_write_dib(QDataStream &s, QImage image)
|
|||||||
|
|
||||||
if (nbits == 1 || nbits == 8) { // direct output
|
if (nbits == 1 || nbits == 8) { // direct output
|
||||||
for (y=image.height()-1; y>=0; y--) {
|
for (y=image.height()-1; y>=0; y--) {
|
||||||
if (d->write((char*)image.scanLine(y), bpl) == -1)
|
if (d->write((char*)image.constScanLine(y), bpl) == -1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -632,12 +632,12 @@ bool qt_write_dib(QDataStream &s, QImage image)
|
|||||||
|
|
||||||
uchar *buf = new uchar[bpl_bmp];
|
uchar *buf = new uchar[bpl_bmp];
|
||||||
uchar *b, *end;
|
uchar *b, *end;
|
||||||
register uchar *p;
|
register const uchar *p;
|
||||||
|
|
||||||
memset(buf, 0, bpl_bmp);
|
memset(buf, 0, bpl_bmp);
|
||||||
for (y=image.height()-1; y>=0; y--) { // write the image bits
|
for (y=image.height()-1; y>=0; y--) { // write the image bits
|
||||||
if (nbits == 4) { // convert 8 -> 4 bits
|
if (nbits == 4) { // convert 8 -> 4 bits
|
||||||
p = image.scanLine(y);
|
p = image.constScanLine(y);
|
||||||
b = buf;
|
b = buf;
|
||||||
end = b + image.width()/2;
|
end = b + image.width()/2;
|
||||||
while (b < end) {
|
while (b < end) {
|
||||||
@ -647,8 +647,8 @@ bool qt_write_dib(QDataStream &s, QImage image)
|
|||||||
if (image.width() & 1)
|
if (image.width() & 1)
|
||||||
*b = *p << 4;
|
*b = *p << 4;
|
||||||
} else { // 32 bits
|
} else { // 32 bits
|
||||||
QRgb *p = (QRgb *)image.scanLine(y);
|
const QRgb *p = (const QRgb *)image.constScanLine(y);
|
||||||
QRgb *end = p + image.width();
|
const QRgb *end = p + image.width();
|
||||||
b = buf;
|
b = buf;
|
||||||
while (p < end) {
|
while (p < end) {
|
||||||
*b++ = qBlue(*p);
|
*b++ = qBlue(*p);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user