Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / common / image-loader.h
1 #ifndef __DALI_TIZEN_PLATFORM_IMAGE_LOADER_H__
2 #define __DALI_TIZEN_PLATFORM_IMAGE_LOADER_H__
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/images/image-operations.h>
22 #include <dali/integration-api/resource-types.h>
23 #include <dali/integration-api/bitmap.h>
24 #include <dali/public-api/images/pixel-data.h>
25 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
26 #include <string>
27
28 namespace Dali
29 {
30 namespace Integration
31 {
32 typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
33 } // Integration
34
35 namespace TizenPlatform
36 {
37 namespace ImageLoader
38 {
39 /**
40  * Convert a file stream into a bitmap.
41  * @param[in] resource The resource to convert.
42  * @param[in] path The path to the resource.
43  * @param[in] fp File Pointer. Closed on exit.
44  * @param[out] bitmap Pointer to write bitmap to
45  * @return true on success, false on failure
46  */
47 bool ConvertStreamToBitmap( const Integration::BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
48
49 /**
50  * Convert a bitmap and write to a file stream.
51  * @param[in] path The path to the resource.
52  * @param[in] fp File Pointer. Closed on exit.
53  * @param[out] pixelData Reference to PixelData object.
54  * @return true on success, false on failure
55  */
56 bool ConvertBitmapToStream( std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
57
58 /**
59  * Loads an image synchronously
60  * @param resource details of the image
61  * @param path to the image
62  * @return bitmap
63  */
64 Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path );
65
66 /**
67  * @returns the closest image size
68  */
69 ImageDimensions  GetClosestImageSize( const std::string& filename,
70                           ImageDimensions size,
71                           FittingMode::Type fittingMode,
72                           SamplingMode::Type samplingMode,
73                           bool orientationCorrection );
74
75 /**
76  * @returns the closest image size
77  */
78 ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
79                           ImageDimensions size,
80                           FittingMode::Type fittingMode,
81                           SamplingMode::Type samplingMode,
82                           bool orientationCorrection );
83
84 } // ImageLoader
85 } // TizenPlatform
86 } // Dali
87
88 #endif // __DALI_TIZEN_PLATFORM_IMAGE_LOADER_H__