* limitations under the License.
*/
+#include <stdio.h>
+#include <stdlib.h>
#include <thumbnail_util.h>
-#include <thumbnail_util_private.h>
-#define MAX_SIZE 4096
+#define TO_BUFFER_PATH "thumb_buffer.raw"
+#define TO_FILE_PATH "thumb_file.jpg"
int main(int argc, char *argv[])
{
- int ret = THUMBNAIL_UTIL_ERROR_NONE;
unsigned char *data = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
FILE *fp;
- char file_name[MAX_SIZE + 1] = {0, };
- thumbnail_util_debug("--- Thumbnail util test start ---");
- thumbnail_util_debug("--- thumbnail_util_extract_to_file start :: IMAGE ---");
- ret = thumbnail_util_extract_to_file(tzplatform_mkpath(TZ_USER_IMAGES, "test_image1.jpg"), 320, 240, tzplatform_mkpath(TZ_USER_IMAGES, "save_image1.jpg"));
- if (ret != THUMBNAIL_UTIL_ERROR_NONE)
- thumbnail_util_debug("thumbnail_util_extract_to_file failed[%d]", ret);
-
- thumbnail_util_debug("--- thumbnail_util_extract_to_buffer start :: IMAGE ---");
- ret = thumbnail_util_extract_to_buffer(tzplatform_mkpath(TZ_USER_IMAGES, "test_image1.jpg"), 320, 240, &data, &size, &width, &height);
- if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
- thumbnail_util_debug("thumbnail_util_extract_to_buffer failed[%d]", ret);
- } else {
- memset(file_name, 0, sizeof(file_name));
- snprintf(file_name, MAX_SIZE, "%s/test_image1.raw", tzplatform_getenv(TZ_USER_IMAGES));
- fp = fopen(file_name, "w");
- fwrite(data, 1, size, fp);
- fclose(fp);
+ if (argc != 2) {
+ printf("Usage : thumbnail_util_test <file path> \n");
+ return 0;
+ }
- if (data) {
- free(data);
- data = NULL;
- }
+ printf("thumbnail_util_extract_to_buffer ---\n\n");
+ if (thumbnail_util_extract_to_buffer(argv[1], 320, 240, &data, &size, &width, &height) != THUMBNAIL_UTIL_ERROR_NONE) {
+ printf("thumbnail_util_extract_to_buffer failed\n");
+ return 0;
}
- thumbnail_util_debug("--- thumbnail_util_extract_to_file start :: VIDEO ---");
- ret = thumbnail_util_extract_to_file(tzplatform_mkpath(TZ_USER_IMAGES, "test_video1.mp4"), 320, 240, tzplatform_mkpath(TZ_USER_IMAGES, "save_video1.jpg"));
- if (ret != THUMBNAIL_UTIL_ERROR_NONE)
- thumbnail_util_debug("thumbnail_util_extract_to_file failed[%d]", ret);
+ printf("thumbnail_util_extract_to_buffer successed ---\n\n");
- thumbnail_util_debug("--- thumbnail_util_extract_to_buffer start :: VIDEO ---");
- ret = thumbnail_util_extract_to_buffer(tzplatform_mkpath(TZ_USER_IMAGES, "test_video1.mp4"), 320, 240, &data, &size, &width, &height);
- if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
- thumbnail_util_debug("thumbnail_util_extract_to_buffer failed[%d]", ret);
- } else {
- memset(file_name, 0, sizeof(file_name));
- snprintf(file_name, MAX_SIZE, "%s/test_video1.raw", tzplatform_getenv(TZ_USER_IMAGES));
- fp = fopen(file_name, "w");
+ if (data && size > 0) {
+ fp = fopen(TO_BUFFER_PATH, "w");
fwrite(data, 1, size, fp);
fclose(fp);
- if (data) {
- free(data);
- data = NULL;
- }
+ free(data);
+ }
+
+ printf("thumbnail_util_extract_to_file ---\n\n");
+ if (thumbnail_util_extract_to_file(argv[1], 320, 240, TO_FILE_PATH) != THUMBNAIL_UTIL_ERROR_NONE) {
+ printf("thumbnail_util_extract_to_file failed\n");
+ return 0;
}
- thumbnail_util_debug("--- Thumbnail util test end ---");
+ printf("thumbnail_util_extract_to_file successed ---\n\n");
return 0;
}