skins/AknSkins/sdcsrc/SDCMBMOutput.cpp
changeset 0 05e9090e2422
child 6 d9c996538b26
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:  Multipart bitmap file output.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "SDCGlobals.h"
       
    19 #include "SDCMBMOutput.h"
       
    20 #include "SDCException.h"
       
    21 
       
    22 //////////////////////////////////////////////////////////////////////
       
    23 // Construction/Destruction
       
    24 //////////////////////////////////////////////////////////////////////
       
    25 
       
    26 CSDCMBMOutput::CSDCMBMOutput()
       
    27     {
       
    28 
       
    29     }
       
    30 
       
    31 CSDCMBMOutput::~CSDCMBMOutput()
       
    32     {
       
    33 
       
    34     }
       
    35 
       
    36 //////////////////////////////////////////////////////////////////////
       
    37 // Other methods
       
    38 //////////////////////////////////////////////////////////////////////
       
    39 
       
    40 void CSDCMBMOutput::Output( CSDCData* aData, const char* aBaseName, const char* aBmconvTxtFilename )
       
    41     {
       
    42     FILE* file = fopen( aBmconvTxtFilename, "wt" );
       
    43     if( !file ) throw CSDCException( ESDCFileOpenError, "Text output file for bmconv can not be opened" );
       
    44 
       
    45     if( aData->IsScalable() )
       
    46         {
       
    47         fprintf( file, "/E\n" );
       
    48         }
       
    49     else
       
    50         {
       
    51         fprintf( file, "%s.mbm\n", aBaseName );
       
    52         }
       
    53 
       
    54     for( int i=0; i<aData->iMbmVector.size(); i++ )
       
    55         {
       
    56         TSDCMBMEntry* entry = aData->iMbmVector[i];
       
    57         if( (entry->iIndex>=16384) && (!aData->IsScalable()) )
       
    58             {
       
    59             throw CSDCException( ESDCContentError, "SVG icons require scalable skin" );
       
    60             }
       
    61 
       
    62         if( aData->IsScalable() )
       
    63             {
       
    64             switch( entry->iColorDepth )
       
    65                 {
       
    66                 case ESDCColorDepth1: fprintf( file, "/1" ); break;
       
    67                 case ESDCColorDepth2: fprintf( file, "/2" ); break;
       
    68                 case ESDCColorDepth4: fprintf( file, "/4" ); break;
       
    69                 case ESDCColorDepth8: fprintf( file, "/8" ); break;
       
    70                 case ESDCColorDepthC4: fprintf( file, "/c4" ); break;
       
    71                 case ESDCColorDepthC8: fprintf( file, "/c8" ); break;
       
    72                 case ESDCColorDepthC12: fprintf( file, "/c12" ); break;
       
    73                 case ESDCColorDepthC16: fprintf( file, "/c16" ); break;
       
    74                 case ESDCColorDepthC24: fprintf( file, "/c24" ); break;
       
    75                 case ESDCColorDepthC32: fprintf( file, "/c32" ); break;
       
    76                 default:
       
    77                     throw CSDCException( ESDCUnknownError, "Unknown color depth value used internally" );
       
    78                 }
       
    79             switch( entry->iMaskColorDepth )
       
    80                 {
       
    81                 case ESDCColorDepthNone: break;
       
    82                 case ESDCColorDepth1: fprintf( file, ",1" ); break;
       
    83                 case ESDCColorDepth2: fprintf( file, ",2" ); break;
       
    84                 case ESDCColorDepth4: fprintf( file, ",4" ); break;
       
    85                 case ESDCColorDepth8: fprintf( file, ",8" ); break;
       
    86                 default:
       
    87                     throw CSDCException( ESDCUnknownError, "Unknown color depth value used internally" );
       
    88                 }
       
    89             fprintf( file, " " );
       
    90             if ( entry->iSvgAnim )
       
    91                 {
       
    92                  fprintf( file, "/A " );
       
    93                 }
       
    94             char pathBuf[512];
       
    95             gInput.ConvertToAscii( pathBuf, entry->iSourcePath );
       
    96             char buf[512];
       
    97             gInput.ConvertToAscii( buf, entry->iSourceFilename );
       
    98             fprintf( file, "%s%s\n", pathBuf, buf );
       
    99             }
       
   100         else
       
   101             {
       
   102             switch( entry->iColorDepth )
       
   103                 {
       
   104                 case ESDCColorDepth1: fprintf( file, "/1" ); break;
       
   105                 case ESDCColorDepth2: fprintf( file, "/2" ); break;
       
   106                 case ESDCColorDepth4: fprintf( file, "/4" ); break;
       
   107                 case ESDCColorDepth8: fprintf( file, "/8" ); break;
       
   108                 case ESDCColorDepthC4: fprintf( file, "/c4" ); break;
       
   109                 case ESDCColorDepthC8: fprintf( file, "/c8" ); break;
       
   110                 case ESDCColorDepthC12: fprintf( file, "/c12" ); break;
       
   111                 case ESDCColorDepthC16: fprintf( file, "/c16" ); break;
       
   112                 case ESDCColorDepthC24: fprintf( file, "/c24" ); break;
       
   113                 case ESDCColorDepthC32: fprintf( file, "/c32" ); break;
       
   114                 default:
       
   115                     throw CSDCException( ESDCUnknownError, "Unknown color depth value used internally" );
       
   116                 }
       
   117             char pathBuf[512];
       
   118             gInput.ConvertToAscii( pathBuf, entry->iSourcePath );
       
   119             char buf[512];
       
   120             gInput.ConvertToAscii( buf, entry->iSourceFilename );
       
   121             fprintf( file, "%s%s\n", pathBuf, buf );
       
   122 
       
   123             switch( entry->iMaskColorDepth )
       
   124                 {
       
   125                 case ESDCColorDepthNone: continue;
       
   126                 case ESDCColorDepth1: fprintf( file, "/1" ); break;
       
   127                 case ESDCColorDepth2: fprintf( file, "/2" ); break;
       
   128                 case ESDCColorDepth4: fprintf( file, "/4" ); break;
       
   129                 case ESDCColorDepth8: fprintf( file, "/8" ); break;
       
   130                 default:
       
   131                     throw CSDCException( ESDCUnknownError, "Unknown color depth value used internally" );
       
   132                 }
       
   133             gInput.ConvertToAscii( pathBuf, entry->iSourcePath );
       
   134             gInput.ConvertToAscii( buf, entry->iMaskSourceFilename );
       
   135             fprintf( file, "%s%s\n", pathBuf, buf );
       
   136             }
       
   137         }
       
   138 
       
   139     fclose( file );
       
   140     }
       
   141 
       
   142 // End of file