Changeset View
Changeset View
Standalone View
Standalone View
plugins/colorengines/lcms2/tests/TestKoCompositeOps.cpp
Show First 20 Lines • Show All 1183 Lines • ▼ Show 20 Line(s) | 1170 | { | |||
---|---|---|---|---|---|
1184 | quint8 * layer = new quint8[pixelCount * pixelSize]; | 1184 | quint8 * layer = new quint8[pixelCount * pixelSize]; | ||
1185 | quint8 * iter = layer; | 1185 | quint8 * iter = layer; | ||
1186 | for (int i = 0; i < pixelCount; i++){ | 1186 | for (int i = 0; i < pixelCount; i++){ | ||
1187 | memcpy(iter, white.data() , pixelSize); | 1187 | memcpy(iter, white.data() , pixelSize); | ||
1188 | iter += pixelSize; | 1188 | iter += pixelSize; | ||
1189 | } | 1189 | } | ||
1190 | 1190 | | |||
1191 | // full white image | 1191 | // full white image | ||
1192 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("0dst.png"); | 1192 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("0dst.png"); | ||
1193 | 1193 | | |||
1194 | // src | 1194 | // src | ||
1195 | quint8 * dab = new quint8[pixelCount * pixelSize]; | 1195 | quint8 * dab = new quint8[pixelCount * pixelSize]; | ||
1196 | iter = dab; | 1196 | iter = dab; | ||
1197 | for (int i = 0; i < pixelCount; i++){ | 1197 | for (int i = 0; i < pixelCount; i++){ | ||
1198 | memcpy(iter, black.data() , pixelSize); | 1198 | memcpy(iter, black.data() , pixelSize); | ||
1199 | iter += pixelSize; | 1199 | iter += pixelSize; | ||
1200 | } | 1200 | } | ||
1201 | 1201 | | |||
1202 | // full black image | 1202 | // full black image | ||
1203 | //cs->convertToQImage(dab, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("1src.png"); | 1203 | //cs->convertToQImage(dab, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("1src.png"); | ||
1204 | 1204 | | |||
1205 | 1205 | | |||
1206 | // selection | 1206 | // selection | ||
1207 | quint32 selectionPixelSize = KoColorSpaceRegistry::instance()->alpha8()->pixelSize(); | 1207 | quint32 selectionPixelSize = KoColorSpaceRegistry::instance()->alpha8()->pixelSize(); | ||
1208 | quint8 * selection = new quint8[pixelCount * selectionPixelSize]; | 1208 | quint8 * selection = new quint8[pixelCount * selectionPixelSize]; | ||
1209 | iter = selection; | 1209 | iter = selection; | ||
1210 | for (int height = 0; height < h; height++){ | 1210 | for (int height = 0; height < h; height++){ | ||
1211 | for (int width = 0; width < w; width++){ | 1211 | for (int width = 0; width < w; width++){ | ||
1212 | if ((height > 128) && (height < 256) && (width > 128) && (width < 256)){ | 1212 | if ((height > 128) && (height < 256) && (width > 128) && (width < 256)){ | ||
1213 | *iter = 255; | 1213 | *iter = 255; | ||
1214 | }else{ | 1214 | }else{ | ||
1215 | *iter = 0; | 1215 | *iter = 0; | ||
1216 | } | 1216 | } | ||
1217 | iter += selectionPixelSize; | 1217 | iter += selectionPixelSize; | ||
1218 | } | 1218 | } | ||
1219 | } | 1219 | } | ||
1220 | 1220 | | |||
1221 | // white rectangle at 128,128 | 1221 | // white rectangle at 128,128 | ||
1222 | //KoColorSpaceRegistry::instance()->alpha8()->convertToQImage(selection, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("1mask.png"); | 1222 | //KoColorSpaceRegistry::instance()->alpha8()->convertToQImage(selection, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("1mask.png"); | ||
1223 | 1223 | | |||
1224 | copy->composite(layer,w * pixelSize, | 1224 | copy->composite(layer,w * pixelSize, | ||
1225 | dab, w * pixelSize, | 1225 | dab, w * pixelSize, | ||
1226 | 0,0, | 1226 | 0,0, | ||
1227 | h, w, | 1227 | h, w, | ||
1228 | 255, | 1228 | 255, | ||
1229 | QBitArray()); | 1229 | QBitArray()); | ||
1230 | 1230 | | |||
1231 | 1231 | | |||
1232 | // full black image | 1232 | // full black image | ||
1233 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("2result.png"); | 1233 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("2result.png"); | ||
1234 | 1234 | | |||
1235 | copy->composite(layer,w * pixelSize, | 1235 | copy->composite(layer,w * pixelSize, | ||
1236 | opaque.data(), 0, | 1236 | opaque.data(), 0, | ||
1237 | 0,0, | 1237 | 0,0, | ||
1238 | h,w, | 1238 | h,w, | ||
1239 | 255, | 1239 | 255, | ||
1240 | QBitArray() | 1240 | QBitArray() | ||
1241 | ); | 1241 | ); | ||
1242 | 1242 | | |||
1243 | // full opaque image | 1243 | // full opaque image | ||
1244 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("3result.png"); | 1244 | //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("3result.png"); | ||
1245 | 1245 | | |||
1246 | copy->composite(layer,w * pixelSize, | 1246 | copy->composite(layer,w * pixelSize, | ||
1247 | dab, w * pixelSize, | 1247 | dab, w * pixelSize, | ||
1248 | selection, w * selectionPixelSize, | 1248 | selection, w * selectionPixelSize, | ||
1249 | h,w, | 1249 | h,w, | ||
1250 | 255, | 1250 | 255, | ||
1251 | QBitArray() | 1251 | QBitArray() | ||
1252 | ); | 1252 | ); | ||
1253 | 1253 | | |||
1254 | // black rectangle on opaque background | 1254 | // black rectangle on opaque background | ||
1255 | QImage result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); | 1255 | QImage result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); | ||
1256 | QImage expectedResult(QString(FILES_DATA_DIR) + QDir::separator() + "CopyWithSelectionExpectedResult.png"); | 1256 | QImage expectedResult(QString(FILES_DATA_DIR) + QDir::separator() + "CopyWithSelectionExpectedResult.png"); | ||
1257 | 1257 | | |||
1258 | bool testOk = (result == expectedResult); | 1258 | bool testOk = (result == expectedResult); | ||
1259 | if (!testOk){ | 1259 | if (!testOk){ | ||
1260 | qDebug() << "Saving the result"; | 1260 | qDebug() << "Saving the result"; | ||
1261 | result.save("CopyWithSelection.png"); | 1261 | result.save("CopyWithSelection.png"); | ||
1262 | } | 1262 | } | ||
1263 | 1263 | | |||
1264 | QVERIFY2(testOk, "Images are not equal"); | 1264 | QVERIFY2(testOk, "Images are not equal"); | ||
1265 | 1265 | | |||
1266 | copy->composite(layer, w * pixelSize, | 1266 | copy->composite(layer, w * pixelSize, | ||
1267 | white.data(), 0, | 1267 | white.data(), 0, | ||
1268 | selection, w * selectionPixelSize, | 1268 | selection, w * selectionPixelSize, | ||
1269 | h,w, | 1269 | h,w, | ||
1270 | 255, | 1270 | 255, | ||
1271 | QBitArray()); | 1271 | QBitArray()); | ||
1272 | 1272 | | |||
1273 | 1273 | | |||
1274 | result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); | 1274 | result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); | ||
1275 | expectedResult = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "CopySingleWithSelectionExpectedResult.png"); | 1275 | expectedResult = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "CopySingleWithSelectionExpectedResult.png"); | ||
1276 | 1276 | | |||
1277 | testOk = (result == expectedResult); | 1277 | testOk = (result == expectedResult); | ||
1278 | if (!testOk){ | 1278 | if (!testOk){ | ||
1279 | qDebug() << expectedResult.size() << result.size(); | 1279 | qDebug() << expectedResult.size() << result.size(); | ||
1280 | for (int row = 0; row < expectedResult.size().height(); ++row) { | 1280 | for (int row = 0; row < expectedResult.size().height(); ++row) { | ||
1281 | for (int col = 0; col < expectedResult.size().width(); ++ col) { | 1281 | for (int col = 0; col < expectedResult.size().width(); ++ col) { | ||
1282 | QRgb res = result.pixel(col, row); | 1282 | QRgb res = result.pixel(col, row); | ||
Show All 17 Lines |