imageeditorengine/filters/FilterGrayScale/Src/CFilterGrayScale.cpp
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "CFilterGrayScale.h"
       
    21 
       
    22 
       
    23 
       
    24 EXPORT_C TInt CFilterGrayScale::Create()
       
    25 	{
       
    26 	CFilterGrayScale* ptr = NULL;
       
    27 	TRAPD( error, ptr = NewL(); );
       
    28 	if( error != KErrNone )
       
    29 		{
       
    30 		ptr = NULL;
       
    31 		}
       
    32 	return (TInt)((MImageFilter*)ptr);
       
    33 	}
       
    34 
       
    35 
       
    36 
       
    37 CFilterGrayScale* CFilterGrayScale::NewL()
       
    38 	{
       
    39 	CFilterGrayScale* self = new( ELeave )CFilterGrayScale();
       
    40 	CleanupStack::PushL( self );
       
    41 	self->ConstructL();
       
    42 	CleanupStack::Pop( self );
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 
       
    47 
       
    48 CFilterGrayScale::~CFilterGrayScale()
       
    49 	{
       
    50 	}
       
    51 
       
    52 
       
    53 
       
    54 CFilterGrayScale::CFilterGrayScale()
       
    55 	{
       
    56 
       
    57 	}
       
    58 
       
    59 
       
    60 
       
    61 void CFilterGrayScale::ConstructL()
       
    62 	{
       
    63 
       
    64 	}
       
    65 
       
    66 
       
    67 
       
    68 TRect CFilterGrayScale::Rect()
       
    69 	{
       
    70 	return iChild->Rect();
       
    71 	}
       
    72 
       
    73 TReal CFilterGrayScale::Scale()
       
    74 	{
       
    75 	return iChild->Scale();
       
    76 	}
       
    77 
       
    78 TSize CFilterGrayScale::ViewPortSize()
       
    79 {
       
    80     return iChild->ViewPortSize();
       
    81 }
       
    82 
       
    83 TBlock * CFilterGrayScale::GetBlockL ( const TRect & aRect )
       
    84 {
       
    85     TBlock * pB = iChild->GetBlockL (aRect);
       
    86     if (!pB) return NULL;
       
    87     TUint32 * pD = pB->iData;
       
    88     for (TInt i = 0; i < pB->iDataLength; ++i)
       
    89     {
       
    90         TUint32 c = *pD;
       
    91 	    TUint32 b = c & 0xFF;
       
    92 	    c >>= 8;
       
    93 	    TUint32 g = c & 0xFF;
       
    94 	    c >>= 8;
       
    95 	    TUint32 r = c & 0xFF;
       
    96 	    TUint32 y = (306 * r + 587 * g + 117 * b) >> 10;
       
    97         *pD++ = (y | (y << 8) | (y << 16));
       
    98     }
       
    99     return pB;
       
   100 }
       
   101 
       
   102 
       
   103 void CFilterGrayScale::SetParent( MImageFilter* aParent )
       
   104 	{
       
   105 	iParent = aParent;
       
   106 	}
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 void CFilterGrayScale::SetChild( MImageFilter* aChild )
       
   112 	{
       
   113 	iChild = aChild;
       
   114 	}
       
   115 
       
   116 
       
   117 
       
   118 TInt CFilterGrayScale::CmdL( const TDesC16& /*aCmd*/ )
       
   119 	{
       
   120     return 0;
       
   121 	}
       
   122 
       
   123 
       
   124 
       
   125 const char* CFilterGrayScale::Type()
       
   126 	{
       
   127 	return "grayscale";
       
   128 	}
       
   129 	
       
   130 #if !defined(EKA2)
       
   131 GLDEF_C TInt E32Dll( TDllReason )
       
   132     {
       
   133     return KErrNone;
       
   134     }	
       
   135 #endif