graphicstools/gdi_tools/bmconv/UTILS.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1997-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 "BMCONV.H"
       
    17 
       
    18 
       
    19 int BitmapUtils::ByteWidth(int aPixelWidth,int aBitsPerPixel)
       
    20 	{
       
    21 	int wordWidth = 0;
       
    22 
       
    23 	switch (aBitsPerPixel)
       
    24 		{
       
    25 	case 1:
       
    26 		wordWidth = (aPixelWidth + 31) / 32;
       
    27 		break;
       
    28 	case 2:
       
    29 		wordWidth = (aPixelWidth + 15) / 16;
       
    30 		break;
       
    31 	case 4:
       
    32 		wordWidth = (aPixelWidth + 7) / 8;
       
    33 		break;
       
    34 	case 8:
       
    35 		wordWidth = (aPixelWidth + 3) / 4;
       
    36 		break;
       
    37 	case 12:
       
    38 	case 16:
       
    39 		wordWidth = (aPixelWidth + 1) / 2;
       
    40 		break;
       
    41 	case 24:
       
    42 		wordWidth = (((aPixelWidth * 3) + 11) / 12) * 3;
       
    43 		break;
       
    44 	case 32:
       
    45 		wordWidth = aPixelWidth;
       
    46 		break;
       
    47 	default:
       
    48 		break;
       
    49 		};
       
    50 
       
    51 	return wordWidth * 4;
       
    52 	}
       
    53