4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "media-thumb-error.h"
23 #include "media-thumb-types.h"
24 #include "media-thumb-debug.h"
25 #include "media-util.h"
26 #include <tzplatform_config.h>
27 #include <gdk-pixbuf/gdk-pixbuf.h>
29 #ifndef _MEDIA_THUMB_UTIL_H_
30 #define _MEDIA_THUMB_UTIL_H_
32 #define SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
34 #ifndef _USE_NEW_MEDIA_DB_
35 #define THUMB_NONE_TYPE 0x00000000 /* None */
36 #define THUMB_IMAGE_TYPE 0x00000001 /* Image */
37 #define THUMB_VIDEO_TYPE 0x00000002 /* Video */
39 #define THUMB_NONE_TYPE -1 /* None */
40 #define THUMB_IMAGE_TYPE 0 /* Image */
41 #define THUMB_VIDEO_TYPE 1 /* Video */
44 #define THUMB_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
45 #define THUMB_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
47 #define THUMB_PHONE_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/phone")
48 #define THUMB_MMC_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/mmc")
50 #define THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png")
54 THUMB_PHONE, /**< Stored only in phone */
55 THUMB_MMC /**< Stored only in MMC */
56 } media_thumb_store_type;
58 int _media_thumb_get_length(media_thumb_type thumb_type);
60 int _media_thumb_get_store_type_by_path(const char *full_path);
63 _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
66 _media_thumb_get_file_type(const char *file_full_path);
69 _media_thumb_remove_file(const char *path);
72 *_media_thumb_generate_hash_name(const char *file);
75 _media_thumb_get_hash_name(const char *file_full_path,
76 char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
79 _media_thumb_save_to_file_with_gdk(GdkPixbuf *data,
86 _media_thumb_get_width(media_thumb_type thumb_type);
89 _media_thumb_get_height(media_thumb_type thumb_type);
92 * _thumbnail_get_data:
93 * This function generates thumbnail raw data, which is wanted by user
94 * This api is closed for a while until being independent from evas object to be thread-safe
96 * @return This function returns zero(MEDIA_THUMB_ERROR_NONE) on success, or negative value with error code.
97 * Please refer 'media-thumb-error.h' to know the exact meaning of the error.
98 * @param[in] origin_path The path of the original image
99 * @param[in] thumb_type The type of the returned thumbnail data
100 * @param[in] format The format of the returned data
101 * @param[out] data The data of generated thumbnail.
102 * @param[out] size The size of generated thumbnail.
103 * @param[out] width The width of generated thumbnail.
104 * @param[out] height The height of generated thumbnail.
105 * @param[out] origin_width The width of original image.
106 * @param[out] origin_height The height of original image.
114 #include <media-thumbnail.h>
116 void test_get_thumb_data()
118 int ret = MEDIA_THUMB_ERROR_NONE;
120 const char *origin_path = "/opt/usr/media/test.jpg";
124 ret = _thumbnail_get_data(origin_path, thumb_type, thumb_path, &data);
128 printf( "_thumbnail_get_data fails. error code->%d", ret);
136 int _thumbnail_get_data(const char *origin_path,
137 media_thumb_type thumb_type,
138 media_thumb_format format,
139 unsigned char **data,
148 #endif /*_MEDIA_THUMB_UTIL_H_*/