Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / MediaApp / MediaApp / project / src / Image / ImageFlipRotateForm.h
1 //
2 // Tizen C++ SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.tizenopensource.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef _IMAGE_FLIP_ROTATE_FORM_H_
19 #define _IMAGE_FLIP_ROTATE_FORM_H_
20
21 #include <FBase.h>
22 #include <FUi.h>
23 #include <FGraphics.h>
24
25 #include "MultiForm.h"
26 #include "BrowserForm.h"
27 #include "Yuv2Rgb.h"
28 #include "BitmapControl.h"
29
30 using namespace Osp::Base::Collection;
31 using namespace Osp::App;
32
33 using namespace Osp::Base;
34 using namespace Osp::Ui;
35 using namespace Osp::Ui::Controls;
36
37 using namespace Osp::Base::Runtime;
38 using namespace Osp::Graphics;
39 using namespace Osp::Media;
40
41
42 class MediaFileBrowser;
43
44 typedef void (*FormBackFunc)(void* bacParam);
45
46 class ImageFlipRotateFormParam
47 {
48 public:
49         ImageFlipRotateFormParam(String root, String filter)
50         {
51                 browserParam.initDir = root;
52                 browserParam.filter = filter;
53         }
54         BrowserFormParam& GetBrowserFormParam() { return browserParam; }
55         void SetFileName(String fileName)
56         {
57                 browserParam.fileName = fileName;
58         }
59         String& GetFileName() { return browserParam.fileName; }
60
61 private:
62         BrowserFormParam browserParam;
63
64         friend class ImageFlipRotateForm;
65 };
66
67 class ImageFlipRotateForm
68         : public MultiForm
69 {
70 public:
71         ImageFlipRotateForm();
72         virtual ~ImageFlipRotateForm();
73         bool Initialize(void);
74
75         static result TestFunc(ImageFlipRotateFormParam* pParam);
76
77 protected:
78         virtual result OnActivate(void* activateParam);
79
80         result OnInitializing(void);
81         void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
82
83         void OpenFile(String filePath);
84
85         virtual void OnUserEventReceivedN(RequestId requestId, Osp::Base::Collection::IList* pArgs);
86         void OnFormBackRequested(Osp::Ui::Controls::Form& source);
87         result LoadConfig(int index);
88         result Process(int index);
89
90         result LoadSource();
91         result RotateImage();
92         result FlipImage();
93
94         Bitmap* GetBitmapN(ByteBuffer& srcBuf, Dimension dim, MediaPixelFormat pixelFormat);
95
96         void UpdateLog(result r);
97
98 private:
99         CONST_INT(ID_BACK);
100         CONST_INT(ID_PREV);
101         CONST_INT(ID_NEXT);
102         CONST_INT(ID_FLIP);
103         CONST_INT(ID_ROTATE);
104         CONST_INT(ID_PROCESS);
105         CONST_INT(ID_RELOAD);
106
107 private:
108         Bitmap* __pSrcBitmap;
109         Bitmap* __pFlipBitmap;
110         Bitmap* __pRotateBitmap;
111         ByteBuffer* __pSrcBuffer;
112         ByteBuffer* __pFlipBuffer;
113         ByteBuffer* __pRotateBuffer;
114         EditArea* __pEditAreaLog;
115         Button* __pFlipButton;
116         Button* __pRotateButton;
117         String __srcName;
118         int __srcWidth;
119         int __srcHeight;
120         MediaPixelFormat __srcPixel;
121         MediaPixelFormat __dstPixel;
122         Yuv2Rgb yuv2rgb;
123         float __bytesPerPixel;
124         ImageFlipType __flipType;
125         ImageRotationType __rotateType;
126         BitmapPixelFormat __bmpFormat;
127         Image __img;
128
129         BitmapControl* __pFlipBmpCtrl;
130         BitmapControl* __pRotateBmpCtrl;
131 };
132
133 #endif // _IMAGE_FLIP_ROTATE_FORM_H_