os/graphics/graphicsdeviceinterface/gdi/tgdi/TRGB.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <palette.h>
    17 #include "TRGB.H"
    18 
    19 
    20 CTRgb::CTRgb(CTestStep* aStep):
    21 	CTGraphicsBase(aStep)
    22 	{
    23 	INFO_PRINTF1(_L("Testing TRgb colour functions"));
    24 	}
    25 
    26 void CTRgb::RunTestCaseL(TInt aCurTestCase)
    27 	{
    28 	((CTRgbStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    29 	switch(aCurTestCase)
    30 		{
    31 	case 1:
    32 /**
    33    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0001
    34 */
    35         	((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0001"));
    36 		TestGray2();
    37 		break;
    38 	case 2:
    39 /**
    40    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0002
    41 */
    42 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0002"));
    43 		TestGray4();
    44 		break;
    45 	case 3:
    46 /**
    47    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0003
    48 */
    49 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0003"));
    50 		TestGray16();
    51 		break;
    52 	case 4:
    53 /**
    54    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0004
    55 */
    56 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0004"));
    57 		TestGray256();
    58 		break;
    59 	case 5:
    60 /**
    61    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0005
    62 */
    63 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0005"));
    64 		TestColor16();
    65 		break;
    66 	case 6:
    67 /**
    68    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0006
    69 */
    70 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0006"));
    71 		TestColor256();
    72 		break;
    73 	case 7:
    74 /**
    75    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0007
    76 */
    77 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0007"));
    78 		TestColor4K();
    79 		break;
    80 	case 8:
    81 /**
    82    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0008
    83 */
    84 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0008"));
    85 		TestColor64K();
    86 		break;
    87 	case 9:
    88 /**
    89    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0009
    90 */
    91 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0009"));
    92 		TestColor16M();
    93 		break;
    94 	case 10:
    95 /**
    96    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0010
    97 */
    98 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0010"));
    99 		TestColor16MU();
   100 		break;
   101 	case 11:
   102 /**
   103    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0011
   104 */
   105 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0011"));
   106 		TestColor16MA();
   107 		break;
   108 	case 12:
   109 /**
   110    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0012
   111 */
   112 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0012"));
   113 		TestColor256Util();
   114 		break;
   115 	case 13:
   116 /**
   117    @SYMTestCaseID          	GRAPHICS-GDI-RGB-0013
   118 */
   119 		((CTRgbStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-RGB-0013"));
   120 		TestColor16MAP();
   121 		break;
   122 	case 14:
   123 		((CTRgbStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   124 		((CTRgbStep*)iStep)->CloseTMSGraphicsStep();
   125 		TestComplete();
   126 		break;
   127 		}
   128 	    ((CTRgbStep*)iStep)->RecordTestResultL();
   129 	}
   130 
   131 /**
   132 	Test Gray2 colour set
   133 
   134 	Cycle through each Gray2 colour & compare the grayscale value used to create the colour
   135 	against the index value retrieved from the colour palette.
   136 	Cycle through a series of RGB values & compare the Gray2 TRgb value with a subset of the Gray256 colour-set.
   137  
   138     Expect the conversion from index value to grayscale colour value & back again produces identical value.
   139 	Expect the Gray2 rgb colour set forms a subset of the Gray256 colour rgb set
   140 */		
   141 void CTRgb::TestGray2()
   142 	{
   143 	INFO_PRINTF1(_L("Gray2"));
   144 
   145 	for (TInt index = 0; index < 2; index++)
   146 		{
   147 		TRgb color = TRgb::Gray2(index);
   148 		TEST(color.Gray2() == index);
   149 		}
   150 
   151 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   152 		{
   153 		TRgb color(value);
   154 		TEST(color.Gray2() == color.Gray256() / 128);
   155 		}
   156 	}
   157 
   158 /**
   159 	Cycle through each Gray4 colour & compare the grayscale value used to create the colour
   160 	against the index value retrieved from the colour palette.
   161 	Cycle through a series of RGB values & compare the Gray4 TRgb colour value with a subset of the Gray256 colour-set.
   162  
   163    	Expect conversion from index value to grayscale colour value & back again produces identical value.
   164 	Expect the Gray4 rgb colour set forms a subset of the Gray256 colour rgb set
   165 */		
   166 void CTRgb::TestGray4()
   167 	{
   168 	INFO_PRINTF1(_L("Gray4"));
   169 
   170 	for (TInt index = 0; index < 4; index++)
   171 		{
   172 		TRgb color = TRgb::Gray4(index);
   173 		TEST(color.Gray4() == index);
   174 		}
   175 
   176 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   177 		{
   178 		TRgb color(value);
   179 		TEST(color.Gray4() == color.Gray256() / 64);
   180 		}
   181 	}
   182 
   183 /**
   184    	Cycle through each Gray16 colour & compare the grayscale value used to create the colour
   185 	against the index value retrieved from the colour palette.
   186 	Cycle through a series of RGB values & compare the Gray16 TRgb value with a subset of the Gray256 colour-set.
   187  
   188    	Expect the conversion from index value to grayscale colour value & back again produces identical value.
   189 	Expect the Gray16 rgb colour set forms a subset of the Gray256 colour rgb set
   190 */		
   191 void CTRgb::TestGray16()
   192 	{
   193 	INFO_PRINTF1(_L("Gray16"));
   194 
   195 	for (TInt index = 0; index < 16; index++)
   196 		{
   197 		TRgb color = TRgb::Gray16(index);
   198 		TEST(color.Gray16() == index);
   199 		}
   200 
   201 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   202 		{
   203 		TRgb color(value);
   204 		TEST(color.Gray16() == color.Gray256() / 16);
   205 		}
   206 	}
   207 
   208 /**
   209    	Cycle through each Gray256 colour & compare the grayscale value used to create the colour
   210 	against the index value retrieved from the colour palette.
   211 	Cycle through a series of RGB values & compare the Gray256 TRgb colour value with the value produced by generic algorithm
   212  
   213    	Expect the conversion from index value to grayscale colour value & back again produces identical value.
   214 	Confirm the algorithm used to produce Gray256 colour set 
   215 */		
   216 void CTRgb::TestGray256()
   217 	{
   218 	INFO_PRINTF1(_L("Gray256"));
   219 
   220 	for (TInt index = 0; index < 256; index++)
   221 		{
   222 		TRgb color = TRgb::Gray256(index);
   223 		TEST(color.Gray256() == index);
   224 		}
   225 
   226 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   227 		{
   228 		TRgb color(value);
   229 		TInt algGray256 = (((value & 0xff) * 2) + (((value >> 8) & 0xff) * 5) + ((value >> 16) & 0xff)) / 8;
   230 		TEST(color.Gray256() == algGray256);
   231 		}
   232 	}
   233 
   234 /**
   235    	Test 16 Colour colour set
   236 
   237    	Cycle through each Color16 colour & test the value used to create the colour
   238 	against the index value retrieved from the colour palette.
   239 	Compare the rgb value for each Color16 colour matches that returned by the DynamicPalette colour palette
   240  
   241    	Expect the RGB colour value returned matches the 16colour palette
   242 */		
   243 void CTRgb::TestColor16()
   244 	{
   245 	INFO_PRINTF1(_L("Color16"));
   246 
   247 	for (TInt index = 0; index < 16; index++)
   248 		{
   249 		TRgb color = TRgb::Color16(index);
   250 		TEST(color.Color16() == index);
   251 		TEST(TRgb::Color16(index) == TRgb(DynamicPalette::Color16array()[index]));
   252 		}
   253 	}
   254 
   255 /**
   256 	Test 256 colour set
   257 
   258     Cycle through each Color256 colour & test the value used to create the colour
   259 	against the index value retrieved from the colour palette.
   260 	Compare the rgb value for each Color256 colour against the rgb value returned by the DynamicPalette colour palette
   261 	Cycle through each Color256 colour & confirm it matches the Netscape Colour Cube
   262 							
   263    	Expect the RGB colour returned matches the 256 colour palette
   264 */
   265 void CTRgb::TestColor256()
   266 	{
   267 	INFO_PRINTF1(_L("Color256"));
   268 
   269 	const TInt mainValues[6] = {0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
   270 	const TInt lowerValues[5] = {0x11, 0x22, 0x44, 0x55, 0x77 };
   271 	const TInt upperValues[5] = {0x88, 0xaa, 0xbb, 0xdd, 0xee };
   272 
   273 	TInt index;
   274 	for (index = 0; index < 256; index++)
   275 		{
   276 		TRgb color = TRgb::Color256(index);
   277 		TEST(color.Color256() == index);
   278 		TEST(TRgb::Color256(index) == TRgb(DynamicPalette::DefaultColor256Util()->iColorTable[index]));
   279 		}
   280 
   281 	for (index = 0; index < 108; index++)
   282 		{
   283 		TRgb color = TRgb::Color256(index);
   284 		TEST(color.Red() == mainValues[index % 6]);
   285 		TEST(color.Green() == mainValues[(index / 6) % 6]);
   286 		TEST(color.Blue() == mainValues[(index / 36) % 6]);
   287 		}
   288 	for (; index < 113; index++)
   289 		{
   290 		TRgb color = TRgb::Color256(index);
   291 		TEST(color.Red() == color.Green());
   292 		TEST(color.Green() == color.Blue());
   293 		TEST(color.Blue() == lowerValues[index - 108]);
   294 		}
   295 	for (; index < 118; index++)
   296 		{
   297 		TRgb color = TRgb::Color256(index);
   298 		TEST(color.Red() == lowerValues[index - 113]);
   299 		TEST(color.Green() == 0);
   300 		TEST(color.Blue() == 0);
   301 		}
   302 	for (; index < 123; index++)
   303 		{
   304 		TRgb color = TRgb::Color256(index);
   305 		TEST(color.Red() == 0);
   306 		TEST(color.Green() == lowerValues[index - 118]);
   307 		TEST(color.Blue() == 0);
   308 		}
   309 	for (; index < 128; index++)
   310 		{
   311 		TRgb color = TRgb::Color256(index);
   312 		TEST(color.Red() == 0);
   313 		TEST(color.Green() == 0);
   314 		TEST(color.Blue() == lowerValues[index - 123]);
   315 		}
   316 	for (; index < 133; index++)
   317 		{
   318 		TRgb color = TRgb::Color256(index);
   319 		TEST(color.Red() == 0);
   320 		TEST(color.Green() == 0);
   321 		TEST(color.Blue() == upperValues[index - 128]);
   322 		}
   323 	for (; index < 138; index++)
   324 		{
   325 		TRgb color = TRgb::Color256(index);
   326 		TEST(color.Red() == 0);
   327 		TEST(color.Green() == upperValues[index - 133]);
   328 		TEST(color.Blue() == 0);
   329 		}
   330 	for (; index < 143; index++)
   331 		{
   332 		TRgb color = TRgb::Color256(index);
   333 		TEST(color.Red() == upperValues[index - 138]);
   334 		TEST(color.Green() == 0);
   335 		TEST(color.Blue() == 0);
   336 		}
   337 	for (; index < 148; index++)
   338 		{
   339 		TRgb color = TRgb::Color256(index);
   340 		TEST(color.Red() == color.Green());
   341 		TEST(color.Green() == color.Blue());
   342 		TEST(color.Blue() == upperValues[index - 143]);
   343 		}
   344 	for (; index < 256; index++)
   345 		{
   346 		TRgb color = TRgb::Color256(index);
   347 		TEST(color.Red() == mainValues[(index - 40) % 6]);
   348 		TEST(color.Green() == mainValues[((index - 40) / 6) % 6]);
   349 		TEST(color.Blue() == mainValues[((index - 40) / 36) % 6]);
   350 		}
   351 	}
   352 
   353 /**
   354 	Test 4096 colour set
   355 
   356    	Cycle through each Color4K colour & compare the colorscale value used to create the colour
   357 	against the index value retrieved from the colour palette.
   358 	Cycle through a series of RGB values & compare the Color4K TRgb value against that produced by the algorithm
   359  
   360    	Confirm the conversion from index value to 4096 colour value & back again produces identical value.
   361 	Confirm the algorithm used to produce 4096 colour set
   362 */	
   363 void CTRgb::TestColor4K()
   364 	{
   365 	INFO_PRINTF1(_L("Color4K"));
   366 
   367 	for (TInt index = 0; index < 4096; index++)
   368 		{
   369 		TRgb color = TRgb::Color4K(index);
   370 		TEST(color.Color4K() == index);
   371 		}
   372 
   373 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   374 		{
   375 		TRgb color(value);
   376 		TInt color4K = ((value & 0xf00000) >> 20) | ((value & 0x00f000) >> 8) | ((value & 0x0000f0) << 4);
   377 		TEST(color.Color4K() == color4K);
   378 		}
   379 	}
   380 
   381 /**
   382    	Test 64K colour set
   383 
   384    	Cycle through each Color64K colour & compare the TRgb value used to create the colour
   385 	against the index value retrieved from the colour palette.
   386 	Cycle through a series of RGB values & compare the Color64K TRgb value against that produced by the algorithm
   387  
   388    	Confirm the conversion from index value to 64K colour value & back again produces identical value.
   389 	Confirm the algorithm used to produce 64K colour set
   390 */	
   391 void CTRgb::TestColor64K()
   392 	{
   393 	INFO_PRINTF1(_L("Color64K"));
   394 
   395 	for (TInt index = 0; index < 65536; index++)
   396 		{
   397 		TRgb color = TRgb::Color64K(index);
   398 		TEST(color.Color64K() == index);
   399 		}
   400 
   401 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   402 		{
   403 		TRgb color(value);
   404 		TInt color64K = ((value & 0xf8) << 8) + ((value & 0xfc00) >> 5) + ((value & 0xf80000) >> 19);
   405 		TEST(color.Color64K() == color64K);
   406 		}
   407 	}
   408 
   409 /**
   410 	Test 16M colour set
   411 
   412  	Cycle through each Color16M colour & compare the TRgb value used to create the colour
   413 	against the index value retrieved from the colour palette.
   414 	Cycle through a series of RGB values & compare the Color16M TRgb value against that produced by the algorithm
   415  
   416    	Confirm the conversion from index value to 16M colour value & back again produces identical value.
   417 	Confirm the algorithm used to produce 16M colour set
   418 */	
   419 void CTRgb::TestColor16M()
   420 	{
   421 	INFO_PRINTF1(_L("Color16M"));
   422 
   423 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   424 		{
   425 		TRgb color(value);
   426 		TInt color16M = ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16);
   427 		TRgb generatedColor = TRgb::Color16M(color16M);
   428 		TEST(color == generatedColor);
   429 		TEST(color.Color16M() == color16M);
   430 		}
   431 	}
   432 
   433 /**
   434 	Test 16MU colour set
   435 
   436    	Cycle through each Color16MU colour & compare the TRgb value used to create the colour
   437 	against the index value retrieved from the colour palette.
   438 	Cycle through a series of RGB values & compare the Color16MU TRgb value against that produced by the algorithm
   439  
   440    	Confirm the conversion from index value to 16MU colour value & back again produces identical value.
   441 	Confirm the algorithm used to produce 16MU colour set
   442 */	
   443 void CTRgb::TestColor16MU()
   444 	{
   445 	INFO_PRINTF1(_L("Color16MU"));
   446 
   447 	for (TUint32 value = 0; value <= 0x00ffffff; value += 31)
   448 		{
   449 		TRgb color(value);
   450 		TInt color16MU = ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16);
   451 		TRgb generatedColor = TRgb::Color16MU(color16MU);
   452 		TEST(color == generatedColor);
   453 		TEST(color.Color16MU() == color16MU);
   454 		}
   455 	}
   456 
   457 /**
   458    	Test 16MA colour set
   459 
   460    	Cycle through each Color16MA colour & compare the TRgb value used to create the colour
   461 	against the index value retrieved from the colour palette.
   462 	Cycle through a series of RGB values & compare the Color16MA TRgb value against that produced by the algorithm
   463  
   464    	Confirm the conversion from index value to 16MA colour value & back again produces identical value.
   465 	Confirm the algorithm used to produce 16MA colour set
   466 */
   467 void CTRgb::TestColor16MA()
   468 	{
   469 	INFO_PRINTF1(_L("Color16MA"));
   470 
   471 	for (TUint32 high = 0; high <= 0xffff; high += 51)
   472 		for (TUint32 low = 0; low <= 0xffff; low += 51)
   473 			{
   474 			TUint32 value = (high << 16) + low; // '+' operator has higher precedance than '<<'  operator
   475 			TRgb color(value);
   476 			TInt color16MA = (0xff000000 - (value & 0xff000000)) | ((value & 0xff0000) >> 16) | (value & 0x00ff00) | ((value & 0x0000ff) << 16);
   477 			TRgb generatedColor = TRgb::Color16MA(color16MA);
   478 			TEST(color == generatedColor);
   479 			TEST(color.Color16MA() == color16MA);
   480 			}
   481 	}
   482 
   483 /**
   484    	Test TColor256Util
   485 
   486    	Test functionality contained within TColor256Util. 
   487 							
   488    	Confirm TColor256Util converts correctly between TRgb values & the corresponding index in the colour palette
   489 							
   490 */
   491 void CTRgb::TestColor256Util()
   492 	{
   493 	INFO_PRINTF1(_L("TColor256Util"));
   494 
   495 	__UHEAP_MARK;
   496 
   497 	TColor256Util* util = new TColor256Util;
   498 	CPalette* palette = NULL;
   499 	TRAPD(err,palette = CPalette::NewDefaultL(EColor256));
   500 	TEST(err==KErrNone);
   501 	util->Construct(*palette);
   502 	TEST(Mem::Compare((TUint8*)util,sizeof(TColor256Util),(TUint8*)DynamicPalette::DefaultColor256Util(),sizeof(TColor256Util))==0);
   503 
   504 	TInt index;
   505 	for (index = 0; index < 256; index++)
   506 		{
   507 		TRgb color = TRgb::Color256(index);
   508 		TEST(util->Color256(index) == color);
   509 		TEST(util->Color256(color) == index);
   510 		}
   511 
   512 	TRgb* rgbBuffer = new TRgb[256];
   513 	TUint8* indexBuffer = new TUint8[256];
   514 	for (index = 0; index < 256; index++)
   515 		rgbBuffer[index] = TRgb::Color256(index);
   516 	util->Color256(indexBuffer,rgbBuffer,256);
   517 	for (index = 0; index < 256; index++)
   518 		TEST(indexBuffer[index]==index);
   519 
   520 	delete[] rgbBuffer;
   521 	delete[] indexBuffer;
   522 	delete palette;
   523 	delete util;
   524 
   525 	__UHEAP_MARKEND;
   526 	}
   527 
   528 /**
   529 	Validate the PreMultiplied value and the Non PreMultiplied value with the expected values.
   530 	@param aAlpha Alpha value of the color.
   531 	@param aValue The value of the color channel(ie. one of Red,Green or Blue).
   532 	@param aPreMulVal The PreMutiplied color value for aValue.
   533 	@param aNonPreMulValue The Non PreMutiplied value for aValue
   534 						   (i.e the value received by Non PreMutiplying aPreMulVal).
   535 
   536 */
   537 void CTRgb::ValidatePMAndNPM(TInt aAlpha, TInt aValue, TInt aPreMulVal, TInt aNonPreMulValue)
   538 	{
   539 	TInt expPreMulValue = (aValue*(aAlpha+1))/256;
   540 	TInt expNonPreMulValMin = (expPreMulValue * 255) / aAlpha;
   541 	TInt expNonPreMulValMax = expNonPreMulValMin + 1;
   542 	if (expNonPreMulValMax > 255)
   543 		{
   544 		expNonPreMulValMax = 255;
   545 		}
   546 	TEST(expPreMulValue == aPreMulVal);
   547 	TEST(expNonPreMulValMin <= aNonPreMulValue && expNonPreMulValMax >= aNonPreMulValue);
   548 	}
   549 
   550 /**
   551    	DEF103742 - Test the PreMultiply and Non PreMultiply conversion.
   552 
   553    	Convert the color values into PreMultiplied color values and again back to
   554    	the Non PreMultiplied color values.
   555    	Compare the  converted values with the expected values to validate the functionality.
   556  
   557    	Confirm the PreMultiplied and Non PreMultiplied color values match with the expected values.
   558 */		
   559 void CTRgb::TestColor16MAP()
   560 	{
   561 	INFO_PRINTF1(_L("Color16MAP"));
   562 	for (TInt alpha = 0; alpha < 256; alpha += 51)
   563 		{
   564 		for (TUint32 value = 0; value <= 0x00ffffff; value += 0x1f1f)
   565 			{
   566 			TRgb color(value, alpha);
   567 			TUint pmColor = color.Color16MAP();
   568 			TRgb npmColor = TRgb::Color16MAP(pmColor);
   569 
   570 			TInt pmAlpha = (pmColor & 0xFF000000) >> 24;
   571 
   572 			// These really must be right!
   573 			TEST(pmAlpha == alpha);
   574 			TEST(npmColor.Alpha() == alpha);
   575 
   576 			// These definitely ought to be right
   577 			if (alpha == 0)	// Full transparency, expect black
   578 				{
   579 				TEST(pmColor == 0);
   580 				TEST(npmColor.Internal() == 0);
   581 				}
   582 			else if (alpha == 255)	// Full opacity, expect roundtrip
   583 				{
   584 				TEST(pmColor == color.Internal());
   585 				TEST(npmColor == color);
   586 				}
   587 			else
   588 				{
   589 				// Most awkward cases: semi-transparency.
   590 				TInt pmRed   = (pmColor & 0x00FF0000) >> 16;
   591 				TInt pmGreen = (pmColor & 0x0000FF00) >> 8;
   592 				TInt pmBlue  = pmColor & 0xFF;
   593 				ValidatePMAndNPM(alpha, color.Red(), pmRed, npmColor.Red());
   594 				ValidatePMAndNPM(alpha, color.Green(), pmGreen, npmColor.Green());
   595 				ValidatePMAndNPM(alpha, color.Blue(), pmBlue, npmColor.Blue());
   596 				}
   597 			}
   598 		}
   599 	}
   600 
   601 //--------------
   602 __CONSTRUCT_STEP__(Rgb)