153 #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) |
153 #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) |
154 try { |
154 try { |
155 #endif |
155 #endif |
156 //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian); |
156 //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian); |
157 QImage image(7000000, 7000000, QImage::Format_Indexed8); |
157 QImage image(7000000, 7000000, QImage::Format_Indexed8); |
158 image.setNumColors(256); |
158 image.setColorCount(256); |
159 cr = !image.isNull(); |
159 cr = !image.isNull(); |
160 #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) |
160 #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) |
161 } catch (...) { |
161 } catch (...) { |
162 } |
162 } |
163 #endif |
163 #endif |
240 { |
240 { |
241 #if !defined(QT3_SUPPORT) |
241 #if !defined(QT3_SUPPORT) |
242 QSKIP("Qt compiled without Qt3Support", SkipAll); |
242 QSKIP("Qt compiled without Qt3Support", SkipAll); |
243 #else |
243 #else |
244 QImage i(9,5,1,2,QImage::LittleEndian); |
244 QImage i(9,5,1,2,QImage::LittleEndian); |
245 qMemSet(i.bits(), 0, i.numBytes()); |
245 qMemSet(i.bits(), 0, i.byteCount()); |
246 |
246 |
247 i.setDotsPerMeterX(9); |
247 i.setDotsPerMeterX(9); |
248 i.setDotsPerMeterY(5); |
248 i.setDotsPerMeterY(5); |
249 i.fill(0x12345678); |
249 i.fill(0x12345678); |
250 QVERIFY(!i.isNull()); |
250 QVERIFY(!i.isNull()); |
256 // A bunch of verifies to make sure that nothing was lost |
256 // A bunch of verifies to make sure that nothing was lost |
257 QVERIFY(i.dotsPerMeterX() == ni.dotsPerMeterX()); |
257 QVERIFY(i.dotsPerMeterX() == ni.dotsPerMeterX()); |
258 QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY()); |
258 QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY()); |
259 QVERIFY(i.depth() == ni.depth()); |
259 QVERIFY(i.depth() == ni.depth()); |
260 QVERIFY(i.size() == ni.size()); |
260 QVERIFY(i.size() == ni.size()); |
261 QVERIFY(i.numColors() == ni.numColors()); |
261 QVERIFY(i.colorCount() == ni.colorCount()); |
262 #endif |
262 #endif |
263 } |
263 } |
264 |
264 |
265 void tst_QImage::formatHandlersInput_data() |
265 void tst_QImage::formatHandlersInput_data() |
266 { |
266 { |
363 |
363 |
364 // Create the alpha channel |
364 // Create the alpha channel |
365 QImage alphaChannel; |
365 QImage alphaChannel; |
366 if (gray) { |
366 if (gray) { |
367 alphaChannel = QImage(width, height, QImage::Format_Indexed8); |
367 alphaChannel = QImage(width, height, QImage::Format_Indexed8); |
368 alphaChannel.setNumColors(256); |
368 alphaChannel.setColorCount(256); |
369 for (int i=0; i<256; ++i) |
369 for (int i=0; i<256; ++i) |
370 alphaChannel.setColor(i, qRgb(i, i, i)); |
370 alphaChannel.setColor(i, qRgb(i, i, i)); |
371 alphaChannel.fill(alpha); |
371 alphaChannel.fill(alpha); |
372 } else { |
372 } else { |
373 alphaChannel = QImage(width, height, QImage::Format_ARGB32); |
373 alphaChannel = QImage(width, height, QImage::Format_ARGB32); |
925 int h = 13; |
925 int h = 13; |
926 QImage original(w, h, format); |
926 QImage original(w, h, format); |
927 original.fill(qRgb(255,255,255)); |
927 original.fill(qRgb(255,255,255)); |
928 |
928 |
929 if (format == QImage::Format_Indexed8) { |
929 if (format == QImage::Format_Indexed8) { |
930 original.setNumColors(256); |
930 original.setColorCount(256); |
931 for (int i = 0; i < 255; ++i) |
931 for (int i = 0; i < 255; ++i) |
932 original.setColor(i, qRgb(0, i, i)); |
932 original.setColor(i, qRgb(0, i, i)); |
933 } |
933 } |
934 |
934 |
935 if (original.colorTable().isEmpty()) { |
935 if (original.colorTable().isEmpty()) { |
1194 QCOMPARE(imgResult2.text(), result); |
1194 QCOMPARE(imgResult2.text(), result); |
1195 QCOMPARE(imgResult2.textKeys(), listResult); |
1195 QCOMPARE(imgResult2.textKeys(), listResult); |
1196 } |
1196 } |
1197 #endif // QT_NO_IMAGE_TEXT |
1197 #endif // QT_NO_IMAGE_TEXT |
1198 |
1198 |
1199 void tst_QImage::setNumColors() |
1199 void tst_QImage::setColorCount() |
1200 { |
1200 { |
1201 QImage img(0, 0, QImage::Format_Indexed8); |
1201 QImage img(0, 0, QImage::Format_Indexed8); |
1202 QTest::ignoreMessage(QtWarningMsg, "QImage::setNumColors: null image"); |
1202 QTest::ignoreMessage(QtWarningMsg, "QImage::setColorCount: null image"); |
1203 img.setNumColors(256); |
1203 img.setColorCount(256); |
1204 QCOMPARE(img.numColors(), 0); |
1204 QCOMPARE(img.colorCount(), 0); |
1205 } |
1205 } |
1206 |
1206 |
1207 void tst_QImage::setColor() |
1207 void tst_QImage::setColor() |
1208 { |
1208 { |
1209 QImage img(0, 0, QImage::Format_Indexed8); |
1209 QImage img(0, 0, QImage::Format_Indexed8); |
1210 img.setColor(0, qRgba(18, 219, 108, 128)); |
1210 img.setColor(0, qRgba(18, 219, 108, 128)); |
1211 QCOMPARE(img.numColors(), 0); |
1211 QCOMPARE(img.colorCount(), 0); |
1212 |
1212 |
1213 QImage img2(1, 1, QImage::Format_Indexed8); |
1213 QImage img2(1, 1, QImage::Format_Indexed8); |
1214 img2.setColor(0, qRgba(18, 219, 108, 128)); |
1214 img2.setColor(0, qRgba(18, 219, 108, 128)); |
1215 QCOMPARE(img2.numColors(), 1); |
1215 QCOMPARE(img2.colorCount(), 1); |
1216 } |
1216 } |
1217 |
1217 |
1218 /* Just some sanity checking that we don't draw outside the buffer of |
1218 /* Just some sanity checking that we don't draw outside the buffer of |
1219 * the image. Hopefully this will create crashes or at least some |
1219 * the image. Hopefully this will create crashes or at least some |
1220 * random test fails when broken. |
1220 * random test fails when broken. |