equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
64 #if defined(Q_OS_WINCE) && defined(STANDARDSHELL_UI_MODEL) |
64 #if defined(Q_OS_WINCE) && defined(STANDARDSHELL_UI_MODEL) |
65 # define Q_INTERNAL_WIN_NO_THROW __declspec(nothrow) |
65 # define Q_INTERNAL_WIN_NO_THROW __declspec(nothrow) |
66 #else |
66 #else |
67 # define Q_INTERNAL_WIN_NO_THROW |
67 # define Q_INTERNAL_WIN_NO_THROW |
68 #endif |
68 #endif |
|
69 |
|
70 // avoid going through QImage::scanLine() which calls detach |
|
71 #define FAST_SCAN_LINE(data, bpl, y) (data + (y) * bpl) |
69 |
72 |
70 /* |
73 /* |
71 All PNG files load to the minimal QImage equivalent. |
74 All PNG files load to the minimal QImage equivalent. |
72 |
75 |
73 All QImage formats output to reasonably efficient PNG equivalents. |
76 All QImage formats output to reasonably efficient PNG equivalents. |
508 // sanity check palette entries |
511 // sanity check palette entries |
509 if (color_type == PNG_COLOR_TYPE_PALETTE |
512 if (color_type == PNG_COLOR_TYPE_PALETTE |
510 && outImage->format() == QImage::Format_Indexed8) { |
513 && outImage->format() == QImage::Format_Indexed8) { |
511 int color_table_size = outImage->colorCount(); |
514 int color_table_size = outImage->colorCount(); |
512 for (int y=0; y<(int)height; ++y) { |
515 for (int y=0; y<(int)height; ++y) { |
513 uchar *p = outImage->scanLine(y); |
516 uchar *p = FAST_SCAN_LINE(data, bpl, y); |
514 uchar *end = p + width; |
517 uchar *end = p + width; |
515 while (p < end) { |
518 while (p < end) { |
516 if (*p >= color_table_size) |
519 if (*p >= color_table_size) |
517 *p = 0; |
520 *p = 0; |
518 ++p; |
521 ++p; |
850 int bit_depth; |
853 int bit_depth; |
851 int color_type; |
854 int color_type; |
852 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, |
855 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, |
853 0, 0, 0); |
856 0, 0, 0); |
854 |
857 |
855 const uchar *data = image.bits(); |
858 const uchar *data = (static_cast<const QImage *>(&image))->bits(); |
856 int bpl = image.bytesPerLine(); |
859 int bpl = image.bytesPerLine(); |
857 row_pointers = new png_bytep[height]; |
860 row_pointers = new png_bytep[height]; |
858 uint y; |
861 uint y; |
859 for (y=0; y<height; y++) { |
862 for (y=0; y<height; y++) { |
860 row_pointers[y] = (png_bytep)(data + y * bpl); |
863 row_pointers[y] = (png_bytep)(data + y * bpl); |