1425 |
1426 |
1426 TInt CDrawSixteenBppBitmap::WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, |
1427 TInt CDrawSixteenBppBitmap::WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, |
1427 TUint32 aOutlinePenColor, TUint32 aShadowColor, |
1428 TUint32 aOutlinePenColor, TUint32 aShadowColor, |
1428 TUint32 aFillColor, const TUint8* aDataBuffer) |
1429 TUint32 aFillColor, const TUint8* aDataBuffer) |
1429 { |
1430 { |
1430 const TInt alpha = aOutlinePenColor >> 24; |
|
1431 if (alpha==0 || aLength<=0) |
|
1432 return(KErrNone); |
|
1433 DeOrientate(aX,aY); |
1431 DeOrientate(aX,aY); |
1434 TUint16* pixelPtr = PixelAddress(aX,aY); |
1432 TUint16* pixelPtr = PixelAddress(aX,aY); |
1435 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
1433 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
1436 const TUint8* dataBufferPtrLimit = aDataBuffer + aLength; |
1434 const TUint8* dataBufferPtrLimit = aDataBuffer + aLength; |
1437 TInt blendedRedColor; |
1435 TInt blendedRedColor; |
1438 TInt blendedGreenColor; |
1436 TInt blendedGreenColor; |
1439 TInt blendedBlueColor; |
1437 TInt blendedBlueColor; |
|
1438 TUint blendedAlpha; |
1440 TUint32 finalColor; |
1439 TUint32 finalColor; |
|
1440 const TUint16* normTable = PtrTo16BitNormalisationTable(); |
1441 |
1441 |
1442 //Get red color. Equivalent to TRgb::Red() |
1442 //Get red color. Equivalent to TRgb::Red() |
1443 const TInt redOutlinePenColor = (aOutlinePenColor & 0xff0000) >> 16; |
1443 const TInt redOutlinePenColor = (aOutlinePenColor & 0xff0000) >> 16; |
1444 const TInt redShadowColor = (aShadowColor & 0xff0000) >> 16; |
1444 const TInt redShadowColor = (aShadowColor & 0xff0000) >> 16; |
1445 const TInt redFillColor = (aFillColor & 0xff0000) >> 16; |
1445 const TInt redFillColor = (aFillColor & 0xff0000) >> 16; |
1452 //Get blue color. Equivalent to TRgb::Blue() |
1452 //Get blue color. Equivalent to TRgb::Blue() |
1453 const TInt blueOutlinePenColor = aOutlinePenColor & 0xff; |
1453 const TInt blueOutlinePenColor = aOutlinePenColor & 0xff; |
1454 const TInt blueShadowColor = aShadowColor & 0xff; |
1454 const TInt blueShadowColor = aShadowColor & 0xff; |
1455 const TInt blueFillColor = aFillColor & 0xff; |
1455 const TInt blueFillColor = aFillColor & 0xff; |
1456 |
1456 |
|
1457 //Get alpha color. Equivalent to TRgb::Alpha() |
|
1458 const TUint alphaOutlinePenColor = aOutlinePenColor >> 24; |
|
1459 const TUint alphaShadowColor = aShadowColor >> 24; |
|
1460 const TUint alphaFillColor = aFillColor >> 24; |
|
1461 |
1457 while (aDataBuffer < dataBufferPtrLimit) |
1462 while (aDataBuffer < dataBufferPtrLimit) |
1458 { |
1463 { |
1459 TUint8 index = *aDataBuffer++; |
1464 TUint8 index = *aDataBuffer++; |
1460 |
|
1461 if (255 == FourColorBlendLookup[index][KBackgroundColorIndex]) |
1465 if (255 == FourColorBlendLookup[index][KBackgroundColorIndex]) |
1462 { |
1466 { |
1463 //background colour |
1467 //background colour |
1464 //No drawing required so move on to next pixel. |
1468 //No drawing required |
1465 pixelPtr += pixelPtrInc; |
|
1466 continue; |
|
1467 } |
1469 } |
1468 else if (255 == FourColorBlendLookup[index][KFillColorIndex]) |
1470 else if (255 == FourColorBlendLookup[index][KFillColorIndex]) |
1469 { |
1471 { |
1470 //Use fill colour to draw |
1472 //Use fill colour to draw |
1471 finalColor = aFillColor; |
1473 finalColor = aFillColor; |
|
1474 *pixelPtr = Blend32To16((finalColor | 0xff000000), alphaFillColor, *pixelPtr); |
1472 } |
1475 } |
1473 else if (255 == FourColorBlendLookup[index][KShadowColorIndex]) |
1476 else if (255 == FourColorBlendLookup[index][KShadowColorIndex]) |
1474 { |
1477 { |
1475 //Use shadow colour to draw |
1478 //Use shadow colour to draw |
1476 finalColor = aShadowColor; |
1479 finalColor = aShadowColor; |
|
1480 *pixelPtr = Blend32To16((finalColor | 0xff000000), alphaShadowColor, *pixelPtr); |
1477 } |
1481 } |
1478 else if (255 == FourColorBlendLookup[index][KOutlineColorIndex]) |
1482 else if (255 == FourColorBlendLookup[index][KOutlineColorIndex]) |
1479 { |
1483 { |
1480 //Use outline colour to draw |
1484 //Use outline colour to draw |
1481 finalColor = aOutlinePenColor; |
1485 finalColor = aOutlinePenColor; |
|
1486 *pixelPtr = Blend32To16((finalColor | 0xff000000), alphaOutlinePenColor, *pixelPtr); |
1482 } |
1487 } |
1483 else |
1488 else |
1484 { |
1489 { |
1485 //Get the background pixel colour. Using the lookup table to convert 16 to 32 bit colour |
1490 //Get the background pixel colour. Using the lookup table to convert 16 to 32 bit colour |
1486 blendedRedColor = redOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
1491 blendedRedColor = (redOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor + |
1487 redShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
1492 redShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor + |
1488 redFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
1493 redFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16; |
1489 |
1494 |
1490 blendedGreenColor = greenOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
1495 blendedGreenColor = (greenOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor + |
1491 greenShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
1496 greenShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor + |
1492 greenFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
1497 greenFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16; |
1493 |
1498 |
1494 blendedBlueColor = blueOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
1499 blendedBlueColor = (blueOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor + |
1495 blueShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
1500 blueShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor + |
1496 blueFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
1501 blueFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16; |
1497 |
1502 |
1498 TInt backGroundAlpha=FourColorBlendLookup[index][KBackgroundColorIndex]; |
1503 blendedAlpha = (alphaOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
1499 if (backGroundAlpha) |
1504 alphaShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
1500 { |
1505 alphaFillColor * FourColorBlendLookup[index][KFillColorIndex]) >> 8; |
1501 const TUint8* pixelPtr8 = reinterpret_cast<TUint8*>(pixelPtr); |
1506 |
1502 const TUint8 low = *pixelPtr8++; |
1507 finalColor = PMA2NonPMAPixel((blendedAlpha << 24) | (blendedRedColor << 16) | (blendedGreenColor << 8) | blendedBlueColor, normTable); |
1503 const TUint8 high = *pixelPtr8++; |
1508 *pixelPtr = Blend32To16((finalColor | 0xff000000), blendedAlpha, *pixelPtr); |
1504 TUint32 backgroundColor = (*(Convert16to32bppHigh() + high)) | (*(Convert16to32bppLow() + low)); |
|
1505 blendedRedColor += ((backgroundColor & 0xff0000) >> 16) * backGroundAlpha; |
|
1506 blendedGreenColor += ((backgroundColor & 0xff00) >> 8) * backGroundAlpha; |
|
1507 blendedBlueColor += (backgroundColor & 0xff) * backGroundAlpha; |
|
1508 } |
|
1509 //Equivalent to TRgb::TRgb(TUint32) |
|
1510 finalColor = ((blendedRedColor&0xFF00)<<8) | (blendedGreenColor&0xFF00) | (blendedBlueColor>>8); |
|
1511 } |
|
1512 |
|
1513 if (alpha == 0xff) |
|
1514 { |
|
1515 *pixelPtr = Conv32To16(finalColor); |
|
1516 } |
|
1517 else |
|
1518 { |
|
1519 *pixelPtr = Blend32To16NoChecks(finalColor, alpha, *pixelPtr); |
|
1520 } |
1509 } |
1521 pixelPtr += pixelPtrInc; |
1510 pixelPtr += pixelPtrInc; |
1522 } |
1511 } |
1523 return KErrNone; |
1512 return KErrNone; |
1524 } |
1513 } |