|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "mifconv_mbmgenerator.h" |
|
19 #include "mifconv_mbmgenerator_pbmcomp.h" |
|
20 #include "mifconv_util.h" |
|
21 |
|
22 #include <stdio.h> |
|
23 #include <sys/stat.h> |
|
24 |
|
25 BmConv::BmConv(MifConvSourceFileList aSourcefilenames): |
|
26 iSourcefilenames(aSourcefilenames) |
|
27 {} |
|
28 |
|
29 BmConv::~BmConv() { |
|
30 } |
|
31 |
|
32 int BmConv::Compile(const MifConvString& aDestfilename, const MifConvString& aPaletteFilename) |
|
33 { |
|
34 int ret = OutOfRange; |
|
35 |
|
36 BitmapCompiler bmcomp(iSourcefilenames); |
|
37 ret = bmcomp.Compile(aDestfilename, aPaletteFilename); |
|
38 |
|
39 Report(ret); |
|
40 return ret; |
|
41 } |
|
42 |
|
43 /** |
|
44 Returns an informative error message, the result of the program actions performed. |
|
45 @return Informative error string |
|
46 @param aErrorNumber The error returned from the actions performed |
|
47 @param aDestfile The multiple bitmap store file name |
|
48 @param aDestCreated True if the multiple bitmap store has been created/modified |
|
49 */ |
|
50 MifConvString BmConv::ErrorMessage(int aErrorNumber, MifConvString aDestfile="", bool aDestCreated=false) |
|
51 { |
|
52 // Remove the multiple bitmap store if it has been created/modified during an fstream session and there has been an error |
|
53 if((aDestfile.length() > 0) && (aErrorNumber != NoError) && (aDestCreated == true)) |
|
54 { |
|
55 remove(aDestfile.c_str()); |
|
56 } |
|
57 |
|
58 switch(aErrorNumber) |
|
59 { |
|
60 case NoError: |
|
61 return "Success."; |
|
62 case NoMemory: |
|
63 return "Out of memory."; |
|
64 case Files: |
|
65 return "File does not exist"; |
|
66 case SourceFile: |
|
67 return "Bad source file(s)."; |
|
68 case DestFile: |
|
69 return "Bad destination file(s)."; |
|
70 case OutOfRange: |
|
71 return "Number of sources/targets mismatch."; |
|
72 case UnknownCompression: |
|
73 return "Unknown source compression type."; |
|
74 case CompressionError: |
|
75 return "Compression error."; |
|
76 case Bpp: |
|
77 return "Invalid bitmap mode specified."; |
|
78 case PaletteFile: |
|
79 return "Bad palette file."; |
|
80 case PaletteSupportNotImplemented: |
|
81 return "Palettes not supported"; |
|
82 case AlphaFiles: |
|
83 return "Alpha bitmap file does not exist"; |
|
84 case AlphaDimensions: |
|
85 return "Alpha channel bitmap's dimensions don't match pixel bitmap's dimensions."; |
|
86 case AlphaBpp: |
|
87 return "Alpha channel bitmap must be 8bpp."; |
|
88 default: |
|
89 return "Unknown error!"; |
|
90 }; |
|
91 } |
|
92 |
|
93 void BmConv::Report(int aError) |
|
94 { |
|
95 if (aError > 0) |
|
96 { |
|
97 cout << "BMP to MBM conversion error: "; |
|
98 cout << ErrorMessage(aError) << "\n"; |
|
99 } |
|
100 } |