PageRenderTime 398ms CodeModel.GetById 160ms app.highlight 93ms RepoModel.GetById 139ms app.codeStats 1ms

/src/canvas/win32/ftk_bitmap_factory_win32.cpp

http://ftk.googlecode.com/
C++ | 89 lines | 45 code | 15 blank | 29 comment | 8 complexity | 8a894a4cc93b62bb04c4dfea5b45687d MD5 | raw file
 1/*
 2 * File: ftk_bitmap_factory.c    
 3 * Author:  Li XianJing <xianjimli@hotmail.com>
 4 * Brief:   bitmap factory.
 5 *
 6 * Copyright (c) 2009 - 2010  Li XianJing <xianjimli@hotmail.com>
 7 *
 8 * Licensed under the Academic Free License version 2.1
 9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 */
24
25/*
26 * History:
27 * ================================================================
28 * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
29 *
30 */
31#include "ftk_log.h"
32#include "ftk_allocator.h"
33#include "ftk_bitmap_factory.h"
34#ifdef VC6
35#define ULONG_PTR unsigned long*
36#endif 
37
38#include <windows.h>
39#include <gdiplus.h>
40#include "ftk_win32.h"
41
42struct _FtkBitmapFactory
43{
44	int unused;
45};
46
47static FtkBitmap* load_win32 (const char *filename)
48{
49	FtkBitmap* bitmap = NULL;
50	WCHAR wfilename[MAX_PATH] = {0};
51	mbstowcs(wfilename, filename, MAX_PATH);
52	Bitmap* bitmap = Bitmap::FromFile(wfilename);
53
54	return_val_if_fail(bitmap != NULL, NULL);
55
56	if(bitmap->GetWidth() == 0 || bitmap->GetHeight() == 0)
57	{
58		delete bitmap;
59
60		return NULL;
61	}
62
63	return ftk_bitmap_create_with_native(bitmap);
64}
65
66FtkBitmapFactory* ftk_bitmap_factory_create(void)
67{
68	FtkBitmapFactory* thiz = (FtkBitmapFactory*)FTK_ZALLOC(sizeof(FtkBitmapFactory));
69
70	return thiz;
71}
72
73FtkBitmap* ftk_bitmap_factory_load(FtkBitmapFactory* thiz, const char* filename)
74{
75	return_val_if_fail(thiz != NULL && filename != NULL, NULL);
76
77	return load_win32(filename);
78}
79
80Ret        ftk_bitmap_factory_add_decoder(FtkBitmapFactory* thiz, FtkImageDecoder* decoder)
81{
82	return RET_OK;
83}
84
85void       ftk_bitmap_factory_destroy(FtkBitmapFactory* thiz)
86{
87	return;
88}
89