PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/os/android/ftk_image_android_decoder.c

http://ftk.googlecode.com/
C | 42 lines | 34 code | 8 blank | 0 comment | 13 complexity | 8e7d90bfe6db8edc5816f1cfbcfaef85 MD5 | raw file
 1
 2#include "ftk_jni.h"
 3#include "ftk_image_android_decoder.h"
 4
 5static Ret ftk_image_android_decoder_match(FtkImageDecoder* thiz, const char* filename)
 6{
 7	return_val_if_fail(filename != NULL, RET_FAIL);
 8
 9	return (strstr(filename, "bmp") != NULL
10		|| strstr(filename, ".png") != NULL 
11		|| strstr(filename, ".jpg") != NULL
12		|| strstr(filename, ".jpeg") != NULL) ? RET_OK : RET_FAIL;
13}
14
15static FtkBitmap* ftk_image_android_decoder_decode(FtkImageDecoder* thiz, const char* filename)
16{
17	return_val_if_fail(ftk_image_android_decoder_match(thiz, filename) == RET_OK, NULL);
18	filename += 8;
19	return Android_LoadImage(filename);
20}
21
22static void ftk_image_android_decoder_destroy(FtkImageDecoder* thiz)
23{
24	if(thiz != NULL)
25	{
26		FTK_ZFREE(thiz, sizeof(thiz));
27	}
28}
29
30FtkImageDecoder* ftk_image_android_decoder_create(void)
31{
32	FtkImageDecoder* thiz = (FtkImageDecoder*)FTK_ZALLOC(sizeof(FtkImageDecoder));
33
34	if(thiz != NULL)
35	{
36		thiz->match   = ftk_image_android_decoder_match;
37		thiz->decode  = ftk_image_android_decoder_decode;
38		thiz->destroy = ftk_image_android_decoder_destroy;
39	}
40
41	return thiz;
42}