|
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 using System; |
|
18 using System.Collections.Generic; |
|
19 using System.Text; |
|
20 using System.IO; |
|
21 using System.Runtime.InteropServices; |
|
22 using SymbianStructuresLib.Compression.Common; |
|
23 |
|
24 namespace SymbianStructuresLib.Compression.BytePair |
|
25 { |
|
26 public class SymbianDecompressorBytePair : SymbianDecompressor |
|
27 { |
|
28 #region Constructors |
|
29 public SymbianDecompressorBytePair() |
|
30 { |
|
31 } |
|
32 #endregion |
|
33 |
|
34 #region From SymbianDecompressor |
|
35 public override TSymbianCompressionType Type |
|
36 { |
|
37 get { return TSymbianCompressionType.EBytePair; } |
|
38 } |
|
39 |
|
40 protected override int DoDecompressRaw( IntPtr aSource, int aSourceLength, IntPtr aDestination, int aDestinationLength ) |
|
41 { |
|
42 int ret = SymbianBytePairUnpackRaw( aSource, aSourceLength, aDestination, aDestinationLength ); |
|
43 return ret; |
|
44 } |
|
45 |
|
46 protected override int DoDecompressImage( IntPtr aSource, int aSourceLength, IntPtr aDestination, int aDestinationLength, out int aAmountOfSourceRead ) |
|
47 { |
|
48 int ret = 0; |
|
49 aAmountOfSourceRead = 0; |
|
50 IntPtr pAmountSrcRead = Marshal.AllocHGlobal( 4 ); |
|
51 // |
|
52 try |
|
53 { |
|
54 ret = SymbianBytePairUnpackImage( aSource, aSourceLength, aDestination, aDestinationLength, pAmountSrcRead ); |
|
55 aAmountOfSourceRead = (int) Marshal.PtrToStructure( pAmountSrcRead, typeof( Int32 ) ); |
|
56 } |
|
57 finally |
|
58 { |
|
59 Marshal.FreeHGlobal( pAmountSrcRead ); |
|
60 } |
|
61 // |
|
62 return ret; |
|
63 } |
|
64 #endregion |
|
65 |
|
66 #region Properties |
|
67 #endregion |
|
68 |
|
69 #region Native methods |
|
70 [DllImport("SymbianNativeTools.dll")] |
|
71 public static extern int SymbianBytePairUnpackRaw( IntPtr aSource, int aSourceSize, IntPtr aDest, int aDestSize ); |
|
72 [DllImport("SymbianNativeTools.dll")] |
|
73 public static extern int SymbianBytePairUnpackImage( IntPtr aSource, |
|
74 int aSourceSize, |
|
75 IntPtr aDest, |
|
76 int aDestSize, |
|
77 IntPtr aAmountOfSourceRead ); |
|
78 #endregion |
|
79 |
|
80 #region Data members |
|
81 #endregion |
|
82 } |
|
83 } |