5
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2007 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 the License "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 |
|
|
19 |
#include"mgimageresolution.h"
|
|
20 |
|
|
21 |
|
|
22 |
// -----------------------------------------------------------------------------
|
|
23 |
// CImageResolution::NewL
|
|
24 |
// Returns the instance of CImageResolution.
|
|
25 |
// -----------------------------------------------------------------------------
|
|
26 |
CImageResolution* CImageResolution::NewL(TDesC& aUrl)
|
|
27 |
{
|
|
28 |
CImageResolution* self = new(ELeave)CImageResolution();
|
|
29 |
CleanupStack::PushL(self);
|
|
30 |
self->ConstructL(aUrl);
|
|
31 |
CleanupStack::Pop(self);
|
|
32 |
return self;
|
|
33 |
}
|
|
34 |
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
// CImageResolution::ConstructL
|
|
37 |
// Symbian C++ constructor
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
|
|
40 |
void CImageResolution::ConstructL(TDesC& aUrl)
|
|
41 |
{
|
|
42 |
User::LeaveIfError(iFs.Connect());
|
|
43 |
|
|
44 |
User::LeaveIfError(iFile.Open(iFs,aUrl,EFileRead));
|
|
45 |
|
|
46 |
iImageDecoder = CImageDecoder::FileNewL(iFile ,ContentAccess::EPeek );
|
|
47 |
|
|
48 |
}
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CImageResolution::CImageResolution
|
|
52 |
// C++ constructor
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
|
|
55 |
CImageResolution::CImageResolution():iImageDecoder(NULL)
|
|
56 |
{
|
|
57 |
// reset frame info
|
|
58 |
iFrameInfo.iBitsPerPixel = 0;
|
|
59 |
iFrameInfo.iFlags = 0;
|
|
60 |
iFrameInfo.iOverallSizeInPixels = TSize( 0, 0 );
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CImageResolution::CImageResolution
|
|
65 |
// Destructor
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
CImageResolution::~CImageResolution()
|
|
68 |
{
|
|
69 |
iFile.Close();
|
|
70 |
iFs.Close();
|
|
71 |
if(iImageDecoder)
|
|
72 |
{
|
|
73 |
delete iImageDecoder;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CImageResolution::GetresolutionL
|
|
78 |
// This method gets the resolution of image
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
TBool CImageResolution::GetresolutionL(TSize& aSize)
|
|
81 |
{
|
|
82 |
iFrameInfo = iImageDecoder->FrameInfo();
|
|
83 |
|
|
84 |
aSize.iWidth = iFrameInfo.iOverallSizeInPixels.iWidth;
|
|
85 |
aSize.iHeight = iFrameInfo.iOverallSizeInPixels.iHeight;
|
|
86 |
|
|
87 |
if(aSize == TSize(0,0))
|
|
88 |
{
|
|
89 |
return false;
|
|
90 |
}
|
|
91 |
|
|
92 |
return true;
|
|
93 |
|
|
94 |
}
|